-`};Ae.text=function(n,e){return Je(n[e].content)};Ae.html_block=function(n,e){return n[e].content};Ae.html_inline=function(n,e){return n[e].content};function mt(){this.rules=sd({},Ae)}mt.prototype.renderAttrs=function(e){var t,i,r;if(!e.attrs)return"";for(r="",t=0,i=e.attrs.length;t<i;t++)r+=" "+Je(e.attrs[t][0])+'="'+Je(e.attrs[t][1])+'"';return r};mt.prototype.renderToken=function(e,t,i){var r,o="",s=!1,a=e[t];return a.hidden?"":(a.block&&a.nesting!==-1&&t&&e[t-1].hidden&&(o+=`
-`),o+=(a.nesting===-1?"</":"<")+a.tag,o+=this.renderAttrs(a),a.nesting===0&&i.xhtmlOut&&(o+=" /"),a.block&&(s=!0,a.nesting===1&&t+1<e.length&&(r=e[t+1],(r.type==="inline"||r.hidden||r.nesting===-1&&r.tag===a.tag)&&(s=!1))),o+=s?`>
-`:">",o)};mt.prototype.renderInline=function(n,e,t){for(var i,r="",o=this.rules,s=0,a=n.length;s<a;s++)i=n[s].type,typeof o[i]<"u"?r+=o[i](n,s,e,t,this):r+=this.renderToken(n,s,e);return r};mt.prototype.renderInlineAsText=function(n,e,t){for(var i="",r=0,o=n.length;r<o;r++)n[r].type==="text"?i+=n[r].content:n[r].type==="image"?i+=this.renderInlineAsText(n[r].children,e,t):n[r].type==="softbreak"&&(i+=`
-`);return i};mt.prototype.render=function(n,e,t){var i,r,o,s="",a=this.rules;for(i=0,r=n.length;i<r;i++)o=n[i].type,o==="inline"?s+=this.renderInline(n[i].children,e,t):typeof a[o]<"u"?s+=a[n[i].type](n,i,e,t,this):s+=this.renderToken(n,i,e,t);return s};ra.exports=mt});var ui=E((Ib,sa)=>{"use strict";function Ce(){this.__rules__=[],this.__cache__=null}Ce.prototype.__find__=function(n){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===n)return e;return-1};Ce.prototype.__compile__=function(){var n=this,e=[""];n.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(i){e.indexOf(i)<0&&e.push(i)})}),n.__cache__={},e.forEach(function(t){n.__cache__[t]=[],n.__rules__.forEach(function(i){i.enabled&&(t&&i.alt.indexOf(t)<0||n.__cache__[t].push(i.fn))})})};Ce.prototype.at=function(n,e,t){var i=this.__find__(n),r=t||{};if(i===-1)throw new Error("Parser rule not found: "+n);this.__rules__[i].fn=e,this.__rules__[i].alt=r.alt||[],this.__cache__=null};Ce.prototype.before=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.after=function(n,e,t,i){var r=this.__find__(n),o=i||{};if(r===-1)throw new Error("Parser rule not found: "+n);this.__rules__.splice(r+1,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.push=function(n,e,t){var i=t||{};this.__rules__.push({name:n,enabled:!0,fn:e,alt:i.alt||[]}),this.__cache__=null};Ce.prototype.enable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!0,t.push(i)},this),this.__cache__=null,t};Ce.prototype.enableOnly=function(n,e){Array.isArray(n)||(n=[n]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(n,e)};Ce.prototype.disable=function(n,e){Array.isArray(n)||(n=[n]);var t=[];return n.forEach(function(i){var r=this.__find__(i);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+i)}this.__rules__[r].enabled=!1,t.push(i)},this),this.__cache__=null,t};Ce.prototype.getRules=function(n){return this.__cache__===null&&this.__compile__(),this.__cache__[n]||[]};sa.exports=Ce});var la=E(($b,aa)=>{"use strict";var ld=/\r\n?|\n/g,cd=/\0/g;aa.exports=function(e){var t;t=e.src.replace(ld,`
-`),t=t.replace(cd,"\uFFFD"),e.src=t}});var ua=E((Mb,ca)=>{"use strict";ca.exports=function(e){var t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}});var da=E((Fb,ha)=>{"use strict";ha.exports=function(e){var t=e.tokens,i,r,o;for(r=0,o=t.length;r<o;r++)i=t[r],i.type==="inline"&&e.md.inline.parse(i.content,e.md,e.env,i.children)}});var fa=E((qb,pa)=>{"use strict";var ud=O().arrayReplaceAt;function hd(n){return/^<a[>\s]/i.test(n)}function dd(n){return/^<\/a\s*>/i.test(n)}pa.exports=function(e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,w,v,g=e.tokens,k;if(e.md.options.linkify){for(i=0,r=g.length;i<r;i++)if(!(g[i].type!=="inline"||!e.md.linkify.pretest(g[i].content)))for(o=g[i].children,f=0,t=o.length-1;t>=0;t--){if(a=o[t],a.type==="link_close"){for(t--;o[t].level!==a.level&&o[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(hd(a.content)&&f>0&&f--,dd(a.content)&&f++),!(f>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,k=e.md.linkify.match(u),l=[],p=a.level,d=0,k.length>0&&k[0].index===0&&t>0&&o[t-1].type==="text_special"&&(k=k.slice(1)),c=0;c<k.length;c++)m=k[c].url,w=e.md.normalizeLink(m),e.md.validateLink(w)&&(v=k[c].text,k[c].schema?k[c].schema==="mailto:"&&!/^mailto:/i.test(v)?v=e.md.normalizeLinkText("mailto:"+v).replace(/^mailto:/,""):v=e.md.normalizeLinkText(v):v=e.md.normalizeLinkText("http://"+v).replace(/^http:\/\//,""),h=k[c].index,h>d&&(s=new e.Token("text","",0),s.content=u.slice(d,h),s.level=p,l.push(s)),s=new e.Token("link_open","a",1),s.attrs=[["href",w]],s.level=p++,s.markup="linkify",s.info="auto",l.push(s),s=new e.Token("text","",0),s.content=v,s.level=p,l.push(s),s=new e.Token("link_close","a",-1),s.level=--p,s.markup="linkify",s.info="auto",l.push(s),d=k[c].lastIndex);d<u.length&&(s=new e.Token("text","",0),s.content=u.slice(d),s.level=p,l.push(s)),g[i].children=o=ud(o,t,l)}}}}});var ba=E((Bb,ga)=>{"use strict";var ma=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,pd=/\((c|tm|r)\)/i,fd=/\((c|tm|r)\)/ig,md={c:"\xA9",r:"\xAE",tm:"\u2122"};function gd(n,e){return md[e.toLowerCase()]}function bd(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&(t.content=t.content.replace(fd,gd)),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}function vd(n){var e,t,i=0;for(e=n.length-1;e>=0;e--)t=n[e],t.type==="text"&&!i&&ma.test(t.content)&&(t.content=t.content.replace(/\+-/g,"\xB1").replace(/\.{2,}/g,"\u2026").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1\u2014").replace(/(^|\s)--(?=\s|$)/mg,"$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1\u2013")),t.type==="link_open"&&t.info==="auto"&&i--,t.type==="link_close"&&t.info==="auto"&&i++}ga.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(pd.test(e.tokens[t].content)&&bd(e.tokens[t].children),ma.test(e.tokens[t].content)&&vd(e.tokens[t].children))}});var _a=E((Pb,Ca)=>{"use strict";var va=O().isWhiteSpace,ya=O().isPunctChar,wa=O().isMdAsciiPunct,yd=/['"]/,xa=/['"]/g,ka="\u2019";function hi(n,e,t){return n.slice(0,e)+t+n.slice(e+1)}function wd(n,e){var t,i,r,o,s,a,l,c,u,h,d,p,f,m,w,v,g,k,y,_,x;for(y=[],t=0;t<n.length;t++){for(i=n[t],l=n[t].level,g=y.length-1;g>=0&&!(y[g].level<=l);g--);if(y.length=g+1,i.type==="text"){r=i.content,s=0,a=r.length;e:for(;s<a&&(xa.lastIndex=s,o=xa.exec(r),!!o);){if(w=v=!0,s=o.index+1,k=o[0]==="'",u=32,o.index-1>=0)u=r.charCodeAt(o.index-1);else for(g=t-1;g>=0&&!(n[g].type==="softbreak"||n[g].type==="hardbreak");g--)if(n[g].content){u=n[g].content.charCodeAt(n[g].content.length-1);break}if(h=32,s<a)h=r.charCodeAt(s);else for(g=t+1;g<n.length&&!(n[g].type==="softbreak"||n[g].type==="hardbreak");g++)if(n[g].content){h=n[g].content.charCodeAt(0);break}if(d=wa(u)||ya(String.fromCharCode(u)),p=wa(h)||ya(String.fromCharCode(h)),f=va(u),m=va(h),m?w=!1:p&&(f||d||(w=!1)),f?v=!1:d&&(m||p||(v=!1)),h===34&&o[0]==='"'&&u>=48&&u<=57&&(v=w=!1),w&&v&&(w=d,v=p),!w&&!v){k&&(i.content=hi(i.content,o.index,ka));continue}if(v){for(g=y.length-1;g>=0&&(c=y[g],!(y[g].level<l));g--)if(c.single===k&&y[g].level===l){c=y[g],k?(_=e.md.options.quotes[2],x=e.md.options.quotes[3]):(_=e.md.options.quotes[0],x=e.md.options.quotes[1]),i.content=hi(i.content,o.index,x),n[c.token].content=hi(n[c.token].content,c.pos,_),s+=x.length-1,c.token===t&&(s+=_.length-1),r=i.content,a=r.length,y.length=g;continue e}}w?y.push({token:t,pos:o.index,single:k,level:l}):v&&k&&(i.content=hi(i.content,o.index,ka))}}}}Ca.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!yd.test(e.tokens[t].content)||wd(e.tokens[t].children,e)}});var Sa=E((Ob,Ea)=>{"use strict";Ea.exports=function(e){var t,i,r,o,s,a,l=e.tokens;for(t=0,i=l.length;t<i;t++)if(l[t].type==="inline"){for(r=l[t].children,s=r.length,o=0;o<s;o++)r[o].type==="text_special"&&(r[o].type="text");for(o=a=0;o<s;o++)r[o].type==="text"&&o+1<s&&r[o+1].type==="text"?r[o+1].content=r[o].content+r[o+1].content:(o!==a&&(r[a]=r[o]),a++);o!==a&&(r.length=a)}}});var di=E((Nb,Aa)=>{"use strict";function gt(n,e,t){this.type=n,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}gt.prototype.attrIndex=function(e){var t,i,r;if(!this.attrs)return-1;for(t=this.attrs,i=0,r=t.length;i<r;i++)if(t[i][0]===e)return i;return-1};gt.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};gt.prototype.attrSet=function(e,t){var i=this.attrIndex(e),r=[e,t];i<0?this.attrPush(r):this.attrs[i]=r};gt.prototype.attrGet=function(e){var t=this.attrIndex(e),i=null;return t>=0&&(i=this.attrs[t][1]),i};gt.prototype.attrJoin=function(e,t){var i=this.attrIndex(e);i<0?this.attrPush([e,t]):this.attrs[i][1]=this.attrs[i][1]+" "+t};Aa.exports=gt});var La=E((Rb,Ta)=>{"use strict";var xd=di();function Da(n,e,t){this.src=n,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Da.prototype.Token=xd;Ta.exports=Da});var $a=E((zb,Ia)=>{"use strict";var kd=ui(),Wr=[["normalize",la()],["block",ua()],["inline",da()],["linkify",fa()],["replacements",ba()],["smartquotes",_a()],["text_join",Sa()]];function Gr(){this.ruler=new kd;for(var n=0;n<Wr.length;n++)this.ruler.push(Wr[n][0],Wr[n][1])}Gr.prototype.process=function(n){var e,t,i;for(i=this.ruler.getRules(""),e=0,t=i.length;e<t;e++)i[e](n)};Gr.prototype.State=La();Ia.exports=Gr});var qa=E((Hb,Fa)=>{"use strict";var Zr=O().isSpace;function Kr(n,e){var t=n.bMarks[e]+n.tShift[e],i=n.eMarks[e];return n.src.slice(t,i)}function Ma(n){var e=[],t=0,i=n.length,r,o=!1,s=0,a="";for(r=n.charCodeAt(t);t<i;)r===124&&(o?(a+=n.substring(s,t-1),s=t):(e.push(a+n.substring(s,t)),a="",s=t+1)),o=r===92,t++,r=n.charCodeAt(t);return e.push(a+n.substring(s)),e}Fa.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,w,v,g,k,y,_,x;if(t+2>i||(u=t+1,e.sCount[u]<e.blkIndent)||e.sCount[u]-e.blkIndent>=4||(a=e.bMarks[u]+e.tShift[u],a>=e.eMarks[u])||(_=e.src.charCodeAt(a++),_!==124&&_!==45&&_!==58)||a>=e.eMarks[u]||(x=e.src.charCodeAt(a++),x!==124&&x!==45&&x!==58&&!Zr(x))||_===45&&Zr(x))return!1;for(;a<e.eMarks[u];){if(o=e.src.charCodeAt(a),o!==124&&o!==45&&o!==58&&!Zr(o))return!1;a++}for(s=Kr(e,t+1),h=s.split("|"),f=[],l=0;l<h.length;l++){if(m=h[l].trim(),!m){if(l===0||l===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(m))return!1;m.charCodeAt(m.length-1)===58?f.push(m.charCodeAt(0)===58?"center":"right"):m.charCodeAt(0)===58?f.push("left"):f.push("")}if(s=Kr(e,t).trim(),s.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(h=Ma(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),d=h.length,d===0||d!==f.length))return!1;if(r)return!0;for(g=e.parentType,e.parentType="table",y=e.md.block.ruler.getRules("blockquote"),p=e.push("table_open","table",1),p.map=w=[t,0],p=e.push("thead_open","thead",1),p.map=[t,t+1],p=e.push("tr_open","tr",1),p.map=[t,t+1],l=0;l<h.length;l++)p=e.push("th_open","th",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l].trim(),p.children=[],p=e.push("th_close","th",-1);for(p=e.push("tr_close","tr",-1),p=e.push("thead_close","thead",-1),u=t+2;u<i&&!(e.sCount[u]<e.blkIndent);u++){for(k=!1,l=0,c=y.length;l<c;l++)if(y[l](e,u,i,!0)){k=!0;break}if(k||(s=Kr(e,u).trim(),!s)||e.sCount[u]-e.blkIndent>=4)break;for(h=Ma(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),u===t+2&&(p=e.push("tbody_open","tbody",1),p.map=v=[t+2,0]),p=e.push("tr_open","tr",1),p.map=[u,u+1],l=0;l<d;l++)p=e.push("td_open","td",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l]?h[l].trim():"",p.children=[],p=e.push("td_close","td",-1);p=e.push("tr_close","tr",-1)}return v&&(p=e.push("tbody_close","tbody",-1),v[1]=u),p=e.push("table_close","table",-1),w[1]=u,e.parentType=g,e.line=u,!0}});var Pa=E((Ub,Ba)=>{"use strict";Ba.exports=function(e,t,i){var r,o,s;if(e.sCount[t]-e.blkIndent<4)return!1;for(o=r=t+1;r<i;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,o=r;continue}break}return e.line=o,s=e.push("code_block","code",0),s.content=e.getLines(t,o,4+e.blkIndent,!1)+`
-`,s.map=[t,e.line],!0}});var Na=E((jb,Oa)=>{"use strict";Oa.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d=!1,p=e.bMarks[t]+e.tShift[t],f=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||p+3>f||(o=e.src.charCodeAt(p),o!==126&&o!==96)||(c=p,p=e.skipChars(p,o),s=p-c,s<3)||(h=e.src.slice(c,p),a=e.src.slice(p,f),o===96&&a.indexOf(String.fromCharCode(o))>=0))return!1;if(r)return!0;for(l=t;l++,!(l>=i||(p=c=e.bMarks[l]+e.tShift[l],f=e.eMarks[l],p<f&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(p)===o&&!(e.sCount[l]-e.blkIndent>=4)&&(p=e.skipChars(p,o),!(p-c<s)&&(p=e.skipSpaces(p),!(p<f)))){d=!0;break}return s=e.sCount[t],e.line=l+(d?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,s,!0),u.markup=h,u.map=[t,e.line],!0}});var Ha=E((Vb,za)=>{"use strict";var Ra=O().isSpace;za.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,w,v,g,k,y,_,x,S,D,q=e.lineMax,L=e.bMarks[t]+e.tShift[t],I=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(L++)!==62)return!1;if(r)return!0;for(l=p=e.sCount[t]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,y=!0):e.src.charCodeAt(L)===9?(y=!0,(e.bsCount[t]+p)%4===3?(L++,l++,p++,o=!1):o=!0):y=!1,f=[e.bMarks[t]],e.bMarks[t]=L;L<I&&(s=e.src.charCodeAt(L),Ra(s));){s===9?p+=4-(p+e.bsCount[t]+(o?1:0))%4:p++;L++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(y?1:0),u=L>=I,g=[e.sCount[t]],e.sCount[t]=p-l,k=[e.tShift[t]],e.tShift[t]=L-e.bMarks[t],x=e.md.block.ruler.getRules("blockquote"),v=e.parentType,e.parentType="blockquote",d=t+1;d<i&&(D=e.sCount[d]<e.blkIndent,L=e.bMarks[d]+e.tShift[d],I=e.eMarks[d],!(L>=I));d++){if(e.src.charCodeAt(L++)===62&&!D){for(l=p=e.sCount[d]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,y=!0):e.src.charCodeAt(L)===9?(y=!0,(e.bsCount[d]+p)%4===3?(L++,l++,p++,o=!1):o=!0):y=!1,f.push(e.bMarks[d]),e.bMarks[d]=L;L<I&&(s=e.src.charCodeAt(L),Ra(s));){s===9?p+=4-(p+e.bsCount[d]+(o?1:0))%4:p++;L++}u=L>=I,m.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(y?1:0),g.push(e.sCount[d]),e.sCount[d]=p-l,k.push(e.tShift[d]),e.tShift[d]=L-e.bMarks[d];continue}if(u)break;for(_=!1,a=0,c=x.length;a<c;a++)if(x[a](e,d,i,!0)){_=!0;break}if(_){e.lineMax=d,e.blkIndent!==0&&(f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),g.push(e.sCount[d]),e.sCount[d]-=e.blkIndent);break}f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),g.push(e.sCount[d]),e.sCount[d]=-1}for(w=e.blkIndent,e.blkIndent=0,S=e.push("blockquote_open","blockquote",1),S.markup=">",S.map=h=[t,0],e.md.block.tokenize(e,t,d),S=e.push("blockquote_close","blockquote",-1),S.markup=">",e.lineMax=q,e.parentType=v,h[1]=e.line,a=0;a<k.length;a++)e.bMarks[a+t]=f[a],e.tShift[a+t]=k[a],e.sCount[a+t]=g[a],e.bsCount[a+t]=m[a];return e.blkIndent=w,!0}});var ja=E((Wb,Ua)=>{"use strict";var Cd=O().isSpace;Ua.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c++),o!==42&&o!==45&&o!==95))return!1;for(s=1;c<u;){if(a=e.src.charCodeAt(c++),a!==o&&!Cd(a))return!1;a===o&&s++}return s<3?!1:(r||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o))),!0)}});var Ka=E((Gb,Za)=>{"use strict";var Ga=O().isSpace;function Va(n,e){var t,i,r,o;return i=n.bMarks[e]+n.tShift[e],r=n.eMarks[e],t=n.src.charCodeAt(i++),t!==42&&t!==45&&t!==43||i<r&&(o=n.src.charCodeAt(i),!Ga(o))?-1:i}function Wa(n,e){var t,i=n.bMarks[e]+n.tShift[e],r=i,o=n.eMarks[e];if(r+1>=o||(t=n.src.charCodeAt(r++),t<48||t>57))return-1;for(;;){if(r>=o)return-1;if(t=n.src.charCodeAt(r++),t>=48&&t<=57){if(r-i>=10)return-1;continue}if(t===41||t===46)break;return-1}return r<o&&(t=n.src.charCodeAt(r),!Ga(t))?-1:r}function _d(n,e){var t,i,r=n.level+2;for(t=e+2,i=n.tokens.length-2;t<i;t++)n.tokens[t].level===r&&n.tokens[t].type==="paragraph_open"&&(n.tokens[t+2].hidden=!0,n.tokens[t].hidden=!0,t+=2)}Za.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,w,v,g,k,y,_,x,S,D,q,L,I,H,R,ee,ge,V,Pe=!1,Oe=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(r&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(Pe=!0),(I=Wa(e,t))>=0){if(h=!0,R=e.bMarks[t]+e.tShift[t],v=Number(e.src.slice(R,I-1)),Pe&&v!==1)return!1}else if((I=Va(e,t))>=0)h=!1;else return!1;if(Pe&&e.skipSpaces(I)>=e.eMarks[t])return!1;if(w=e.src.charCodeAt(I-1),r)return!0;for(m=e.tokens.length,h?(V=e.push("ordered_list_open","ol",1),v!==1&&(V.attrs=[["start",v]])):V=e.push("bullet_list_open","ul",1),V.map=f=[t,0],V.markup=String.fromCharCode(w),k=t,H=!1,ge=e.md.block.ruler.getRules("list"),x=e.parentType,e.parentType="list";k<i;){for(L=I,g=e.eMarks[k],u=y=e.sCount[k]+I-(e.bMarks[t]+e.tShift[t]);L<g;){if(o=e.src.charCodeAt(L),o===9)y+=4-(y+e.bsCount[k])%4;else if(o===32)y++;else break;L++}if(s=L,s>=g?c=1:c=y-u,c>4&&(c=1),l=u+c,V=e.push("list_item_open","li",1),V.markup=String.fromCharCode(w),V.map=d=[t,0],h&&(V.info=e.src.slice(R,I-1)),q=e.tight,D=e.tShift[t],S=e.sCount[t],_=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=s-e.bMarks[t],e.sCount[t]=y,s>=g&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,i):e.md.block.tokenize(e,t,i,!0),(!e.tight||H)&&(Oe=!1),H=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=_,e.tShift[t]=D,e.sCount[t]=S,e.tight=q,V=e.push("list_item_close","li",-1),V.markup=String.fromCharCode(w),k=t=e.line,d[1]=k,s=e.bMarks[t],k>=i||e.sCount[k]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(ee=!1,a=0,p=ge.length;a<p;a++)if(ge[a](e,k,i,!0)){ee=!0;break}if(ee)break;if(h){if(I=Wa(e,k),I<0)break;R=e.bMarks[k]+e.tShift[k]}else if(I=Va(e,k),I<0)break;if(w!==e.src.charCodeAt(I-1))break}return h?V=e.push("ordered_list_close","ol",-1):V=e.push("bullet_list_close","ul",-1),V.markup=String.fromCharCode(w),f[1]=k,e.line=k,e.parentType=x,Oe&&_d(e,m),!0}});var Ya=E((Zb,Xa)=>{"use strict";var Ed=O().normalizeReference,pi=O().isSpace;Xa.exports=function(e,t,i,r){var o,s,a,l,c,u,h,d,p,f,m,w,v,g,k,y,_=0,x=e.bMarks[t]+e.tShift[t],S=e.eMarks[t],D=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(x)!==91)return!1;for(;++x<S;)if(e.src.charCodeAt(x)===93&&e.src.charCodeAt(x-1)!==92){if(x+1===S||e.src.charCodeAt(x+1)!==58)return!1;break}for(l=e.lineMax,k=e.md.block.ruler.getRules("reference"),f=e.parentType,e.parentType="reference";D<l&&!e.isEmpty(D);D++)if(!(e.sCount[D]-e.blkIndent>3)&&!(e.sCount[D]<0)){for(g=!1,u=0,h=k.length;u<h;u++)if(k[u](e,D,l,!0)){g=!0;break}if(g)break}for(v=e.getLines(t,D,e.blkIndent,!1).trim(),S=v.length,x=1;x<S;x++){if(o=v.charCodeAt(x),o===91)return!1;if(o===93){p=x;break}else o===10?_++:o===92&&(x++,x<S&&v.charCodeAt(x)===10&&_++)}if(p<0||v.charCodeAt(p+1)!==58)return!1;for(x=p+2;x<S;x++)if(o=v.charCodeAt(x),o===10)_++;else if(!pi(o))break;if(m=e.md.helpers.parseLinkDestination(v,x,S),!m.ok||(c=e.md.normalizeLink(m.str),!e.md.validateLink(c)))return!1;for(x=m.pos,_+=m.lines,s=x,a=_,w=x;x<S;x++)if(o=v.charCodeAt(x),o===10)_++;else if(!pi(o))break;for(m=e.md.helpers.parseLinkTitle(v,x,S),x<S&&w!==x&&m.ok?(y=m.str,x=m.pos,_+=m.lines):(y="",x=s,_=a);x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;if(x<S&&v.charCodeAt(x)!==10&&y)for(y="",x=s,_=a;x<S&&(o=v.charCodeAt(x),!!pi(o));)x++;return x<S&&v.charCodeAt(x)!==10||(d=Ed(v.slice(1,p)),!d)?!1:(r||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:y,href:c}),e.parentType=f,e.line=t+_+1),!0)}});var Qa=E((Kb,Ja)=>{"use strict";Ja.exports=["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","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var Yr=E((Xb,Xr)=>{"use strict";var Sd="[a-zA-Z_:][a-zA-Z0-9:._-]*",Ad="[^\"'=<>`\\x00-\\x20]+",Dd="'[^']*'",Td='"[^"]*"',Ld="(?:"+Ad+"|"+Dd+"|"+Td+")",Id="(?:\\s+"+Sd+"(?:\\s*=\\s*"+Ld+")?)",el="<[A-Za-z][A-Za-z0-9\\-]*"+Id+"*\\s*\\/?>",tl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",$d="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Md="<[?][\\s\\S]*?[?]>",Fd="<![A-Z]+\\s+[^>]*>",qd="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Bd=new RegExp("^(?:"+el+"|"+tl+"|"+$d+"|"+Md+"|"+Fd+"|"+qd+")"),Pd=new RegExp("^(?:"+el+"|"+tl+")");Xr.exports.HTML_TAG_RE=Bd;Xr.exports.HTML_OPEN_CLOSE_TAG_RE=Pd});var il=E((Yb,nl)=>{"use strict";var Od=Qa(),Nd=Yr().HTML_OPEN_CLOSE_TAG_RE,bt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Od.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Nd.source+"\\s*$"),/^$/,!1]];nl.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(c)!==60)return!1;for(l=e.src.slice(c,u),o=0;o<bt.length&&!bt[o][0].test(l);o++);if(o===bt.length)return!1;if(r)return bt[o][2];if(s=t+1,!bt[o][1].test(l)){for(;s<i&&!(e.sCount[s]<e.blkIndent);s++)if(c=e.bMarks[s]+e.tShift[s],u=e.eMarks[s],l=e.src.slice(c,u),bt[o][1].test(l)){l.length!==0&&s++;break}}return e.line=s,a=e.push("html_block","",0),a.map=[t,s],a.content=e.getLines(t,s,e.blkIndent,!0),!0}});var sl=E((Jb,ol)=>{"use strict";var rl=O().isSpace;ol.exports=function(e,t,i,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c),o!==35||c>=u))return!1;for(s=1,o=e.src.charCodeAt(++c);o===35&&c<u&&s<=6;)s++,o=e.src.charCodeAt(++c);return s>6||c<u&&!rl(o)?!1:(r||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&rl(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(s),1),l.markup="########".slice(0,s),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(c,u).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(s),-1),l.markup="########".slice(0,s)),!0)}});var ll=E((Qb,al)=>{"use strict";al.exports=function(e,t,i){var r,o,s,a,l,c,u,h,d,p=t+1,f,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(f=e.parentType,e.parentType="paragraph";p<i&&!e.isEmpty(p);p++)if(!(e.sCount[p]-e.blkIndent>3)){if(e.sCount[p]>=e.blkIndent&&(c=e.bMarks[p]+e.tShift[p],u=e.eMarks[p],c<u&&(d=e.src.charCodeAt(c),(d===45||d===61)&&(c=e.skipChars(c,d),c=e.skipSpaces(c),c>=u)))){h=d===61?1:2;break}if(!(e.sCount[p]<0)){for(o=!1,s=0,a=m.length;s<a;s++)if(m[s](e,p,i,!0)){o=!0;break}if(o)break}}return h?(r=e.getLines(t,p,e.blkIndent,!1).trim(),e.line=p+1,l=e.push("heading_open","h"+String(h),1),l.markup=String.fromCharCode(d),l.map=[t,e.line],l=e.push("inline","",0),l.content=r,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(h),-1),l.markup=String.fromCharCode(d),e.parentType=f,!0):!1}});var ul=E((ev,cl)=>{"use strict";cl.exports=function(e,t){var i,r,o,s,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),h=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<h&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(r=!1,o=0,s=u.length;o<s;o++)if(u[o](e,c,h,!0)){r=!0;break}if(r)break}return i=e.getLines(t,c,e.blkIndent,!1).trim(),e.line=c,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=i,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var pl=E((tv,dl)=>{"use strict";var hl=di(),fi=O().isSpace;function De(n,e,t,i){var r,o,s,a,l,c,u,h;for(this.src=n,this.md=e,this.env=t,this.tokens=i,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,this.result="",o=this.src,h=!1,s=a=c=u=0,l=o.length;a<l;a++){if(r=o.charCodeAt(a),!h)if(fi(r)){c++,r===9?u+=4-u%4:u++;continue}else h=!0;(r===10||a===l-1)&&(r!==10&&a++,this.bMarks.push(s),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),h=!1,c=0,u=0,s=a+1)}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}De.prototype.push=function(n,e,t){var i=new hl(n,e,t);return i.block=!0,t<0&&this.level--,i.level=this.level,t>0&&this.level++,this.tokens.push(i),i};De.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};De.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};De.prototype.skipSpaces=function(e){for(var t,i=this.src.length;e<i&&(t=this.src.charCodeAt(e),!!fi(t));e++);return e};De.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!fi(this.src.charCodeAt(--e)))return e+1;return e};De.prototype.skipChars=function(e,t){for(var i=this.src.length;e<i&&this.src.charCodeAt(e)===t;e++);return e};De.prototype.skipCharsBack=function(e,t,i){if(e<=i)return e;for(;e>i;)if(t!==this.src.charCodeAt(--e))return e+1;return e};De.prototype.getLines=function(e,t,i,r){var o,s,a,l,c,u,h,d=e;if(e>=t)return"";for(u=new Array(t-e),o=0;d<t;d++,o++){for(s=0,h=l=this.bMarks[d],d+1<t||r?c=this.eMarks[d]+1:c=this.eMarks[d];l<c&&s<i;){if(a=this.src.charCodeAt(l),fi(a))a===9?s+=4-(s+this.bsCount[d])%4:s++;else if(l-h<this.tShift[d])s++;else break;l++}s>i?u[o]=new Array(s-i+1).join(" ")+this.src.slice(l,c):u[o]=this.src.slice(l,c)}return u.join("")};De.prototype.Token=hl;dl.exports=De});var ml=E((nv,fl)=>{"use strict";var Rd=ui(),mi=[["table",qa(),["paragraph","reference"]],["code",Pa()],["fence",Na(),["paragraph","reference","blockquote","list"]],["blockquote",Ha(),["paragraph","reference","blockquote","list"]],["hr",ja(),["paragraph","reference","blockquote","list"]],["list",Ka(),["paragraph","reference","blockquote"]],["reference",Ya()],["html_block",il(),["paragraph","reference","blockquote"]],["heading",sl(),["paragraph","reference","blockquote"]],["lheading",ll()],["paragraph",ul()]];function gi(){this.ruler=new Rd;for(var n=0;n<mi.length;n++)this.ruler.push(mi[n][0],mi[n][1],{alt:(mi[n][2]||[]).slice()})}gi.prototype.tokenize=function(n,e,t){for(var i,r,o=this.ruler.getRules(""),s=o.length,a=e,l=!1,c=n.md.options.maxNesting;a<t&&(n.line=a=n.skipEmptyLines(a),!(a>=t||n.sCount[a]<n.blkIndent));){if(n.level>=c){n.line=t;break}for(r=0;r<s&&(i=o[r](n,a,t,!1),!i);r++);n.tight=!l,n.isEmpty(n.line-1)&&(l=!0),a=n.line,a<t&&n.isEmpty(a)&&(l=!0,a++,n.line=a)}};gi.prototype.parse=function(n,e,t,i){var r;n&&(r=new this.State(n,e,t,i),this.tokenize(r,r.line,r.lineMax))};gi.prototype.State=pl();fl.exports=gi});var bl=E((iv,gl)=>{"use strict";function zd(n){switch(n){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}gl.exports=function(e,t){for(var i=e.pos;i<e.posMax&&!zd(e.src.charCodeAt(i));)i++;return i===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,i)),e.pos=i,!0)}});var yl=E((rv,vl)=>{"use strict";var Hd=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;vl.exports=function(e,t){var i,r,o,s,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(i=e.pos,r=e.posMax,i+3>r)||e.src.charCodeAt(i)!==58||e.src.charCodeAt(i+1)!==47||e.src.charCodeAt(i+2)!==47||(o=e.pending.match(Hd),!o)||(s=o[1],a=e.md.linkify.matchAtStart(e.src.slice(i-s.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),c=e.md.normalizeLink(l),!e.md.validateLink(c))?!1:(t||(e.pending=e.pending.slice(0,-s.length),u=e.push("link_open","a",1),u.attrs=[["href",c]],u.markup="linkify",u.info="auto",u=e.push("text","",0),u.content=e.md.normalizeLinkText(l),u=e.push("link_close","a",-1),u.markup="linkify",u.info="auto"),e.pos+=l.length-s.length,!0)}});var xl=E((ov,wl)=>{"use strict";var Ud=O().isSpace;wl.exports=function(e,t){var i,r,o,s=e.pos;if(e.src.charCodeAt(s)!==10)return!1;if(i=e.pending.length-1,r=e.posMax,!t)if(i>=0&&e.pending.charCodeAt(i)===32)if(i>=1&&e.pending.charCodeAt(i-1)===32){for(o=i-1;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(s++;s<r&&Ud(e.src.charCodeAt(s));)s++;return e.pos=s,!0}});var Cl=E((sv,kl)=>{"use strict";var jd=O().isSpace,Qr=[];for(Jr=0;Jr<256;Jr++)Qr.push(0);var Jr;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(n){Qr[n.charCodeAt(0)]=1});kl.exports=function(e,t){var i,r,o,s,a,l=e.pos,c=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=c))return!1;if(i=e.src.charCodeAt(l),i===10){for(t||e.push("hardbreak","br",0),l++;l<c&&(i=e.src.charCodeAt(l),!!jd(i));)l++;return e.pos=l,!0}return s=e.src[l],i>=55296&&i<=56319&&l+1<c&&(r=e.src.charCodeAt(l+1),r>=56320&&r<=57343&&(s+=e.src[l+1],l++)),o="\\"+s,t||(a=e.push("text_special","",0),i<256&&Qr[i]!==0?a.content=s:a.content=o,a.markup=o,a.info="escape"),e.pos=l+1,!0}});var El=E((av,_l)=>{"use strict";_l.exports=function(e,t){var i,r,o,s,a,l,c,u,h=e.pos,d=e.src.charCodeAt(h);if(d!==96)return!1;for(i=h,h++,r=e.posMax;h<r&&e.src.charCodeAt(h)===96;)h++;if(o=e.src.slice(i,h),c=o.length,e.backticksScanned&&(e.backticks[c]||0)<=i)return t||(e.pending+=o),e.pos+=c,!0;for(a=l=h;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<r&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(s=e.push("code_inline","code",0),s.markup=o,s.content=e.src.slice(h,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=o),e.pos+=c,!0}});var to=E((lv,eo)=>{"use strict";eo.exports.tokenize=function(e,t){var i,r,o,s,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(r=e.scanDelims(e.pos,!0),s=r.length,a=String.fromCharCode(c),s<2))return!1;for(s%2&&(o=e.push("text","",0),o.content=a,s--),i=0;i<s;i+=2)o=e.push("text","",0),o.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Sl(n,e){var t,i,r,o,s,a=[],l=e.length;for(t=0;t<l;t++)r=e[t],r.marker===126&&r.end!==-1&&(o=e[r.end],s=n.tokens[r.token],s.type="s_open",s.tag="s",s.nesting=1,s.markup="~~",s.content="",s=n.tokens[o.token],s.type="s_close",s.tag="s",s.nesting=-1,s.markup="~~",s.content="",n.tokens[o.token-1].type==="text"&&n.tokens[o.token-1].content==="~"&&a.push(o.token-1));for(;a.length;){for(t=a.pop(),i=t+1;i<n.tokens.length&&n.tokens[i].type==="s_close";)i++;i--,t!==i&&(s=n.tokens[i],n.tokens[i]=n.tokens[t],n.tokens[t]=s)}}eo.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Sl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Sl(e,i[t].delimiters)}});var io=E((cv,no)=>{"use strict";no.exports.tokenize=function(e,t){var i,r,o,s=e.pos,a=e.src.charCodeAt(s);if(t||a!==95&&a!==42)return!1;for(r=e.scanDelims(e.pos,a===42),i=0;i<r.length;i++)o=e.push("text","",0),o.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:r.length,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Al(n,e){var t,i,r,o,s,a,l=e.length;for(t=l-1;t>=0;t--)i=e[t],!(i.marker!==95&&i.marker!==42)&&i.end!==-1&&(r=e[i.end],a=t>0&&e[t-1].end===i.end+1&&e[t-1].marker===i.marker&&e[t-1].token===i.token-1&&e[i.end+1].token===r.token+1,s=String.fromCharCode(i.marker),o=n.tokens[i.token],o.type=a?"strong_open":"em_open",o.tag=a?"strong":"em",o.nesting=1,o.markup=a?s+s:s,o.content="",o=n.tokens[r.token],o.type=a?"strong_close":"em_close",o.tag=a?"strong":"em",o.nesting=-1,o.markup=a?s+s:s,o.content="",a&&(n.tokens[e[t-1].token].content="",n.tokens[e[i.end+1].token].content="",t--))}no.exports.postProcess=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Al(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Al(e,i[t].delimiters)}});var Tl=E((uv,Dl)=>{"use strict";var Vd=O().normalizeReference,ro=O().isSpace;Dl.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d="",p="",f=e.pos,m=e.posMax,w=e.pos,v=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,s=e.md.helpers.parseLinkLabel(e,e.pos,!0),s<0))return!1;if(l=s+1,l<m&&e.src.charCodeAt(l)===40){for(v=!1,l++;l<m&&(r=e.src.charCodeAt(l),!(!ro(r)&&r!==10));l++);if(l>=m)return!1;if(w=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(d=e.md.normalizeLink(c.str),e.md.validateLink(d)?l=c.pos:d="",w=l;l<m&&(r=e.src.charCodeAt(l),!(!ro(r)&&r!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&w!==l&&c.ok)for(p=c.str,l=c.pos;l<m&&(r=e.src.charCodeAt(l),!(!ro(r)&&r!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(v=!0),l++}if(v){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(w=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?o=e.src.slice(w,l++):l=s+1):l=s+1,o||(o=e.src.slice(a,s)),u=e.env.references[Vd(o)],!u)return e.pos=f,!1;d=u.href,p=u.title}return t||(e.pos=a,e.posMax=s,h=e.push("link_open","a",1),h.attrs=i=[["href",d]],p&&i.push(["title",p]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,h=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Il=E((hv,Ll)=>{"use strict";var Wd=O().normalizeReference,oo=O().isSpace;Ll.exports=function(e,t){var i,r,o,s,a,l,c,u,h,d,p,f,m,w="",v=e.pos,g=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(c=a+1,c<g&&e.src.charCodeAt(c)===40){for(c++;c<g&&(r=e.src.charCodeAt(c),!(!oo(r)&&r!==10));c++);if(c>=g)return!1;for(m=c,h=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),h.ok&&(w=e.md.normalizeLink(h.str),e.md.validateLink(w)?c=h.pos:w=""),m=c;c<g&&(r=e.src.charCodeAt(c),!(!oo(r)&&r!==10));c++);if(h=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<g&&m!==c&&h.ok)for(d=h.str,c=h.pos;c<g&&(r=e.src.charCodeAt(c),!(!oo(r)&&r!==10));c++);else d="";if(c>=g||e.src.charCodeAt(c)!==41)return e.pos=v,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<g&&e.src.charCodeAt(c)===91?(m=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?s=e.src.slice(m,c++):c=a+1):c=a+1,s||(s=e.src.slice(l,a)),u=e.env.references[Wd(s)],!u)return e.pos=v,!1;w=u.href,d=u.title}return t||(o=e.src.slice(l,a),e.md.inline.parse(o,e.md,e.env,f=[]),p=e.push("image","img",0),p.attrs=i=[["src",w],["alt",""]],p.children=f,p.content=o,d&&i.push(["title",d])),e.pos=c,e.posMax=g,!0}});var Ml=E((dv,$l)=>{"use strict";var Gd=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,Zd=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;$l.exports=function(e,t){var i,r,o,s,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(s=e.src.charCodeAt(c),s===60))return!1;if(s===62)break}return i=e.src.slice(a+1,c),Zd.test(i)?(r=e.md.normalizeLink(i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):Gd.test(i)?(r=e.md.normalizeLink("mailto:"+i),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(i),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=i.length+2,!0):!1):!1}});var ql=E((pv,Fl)=>{"use strict";var Kd=Yr().HTML_TAG_RE;function Xd(n){return/^<a[>\s]/i.test(n)}function Yd(n){return/^<\/a\s*>/i.test(n)}function Jd(n){var e=n|32;return e>=97&&e<=122}Fl.exports=function(e,t){var i,r,o,s,a=e.pos;return!e.md.options.html||(o=e.posMax,e.src.charCodeAt(a)!==60||a+2>=o)||(i=e.src.charCodeAt(a+1),i!==33&&i!==63&&i!==47&&!Jd(i))||(r=e.src.slice(a).match(Kd),!r)?!1:(t||(s=e.push("html_inline","",0),s.content=e.src.slice(a,a+r[0].length),Xd(s.content)&&e.linkLevel++,Yd(s.content)&&e.linkLevel--),e.pos+=r[0].length,!0)}});var Nl=E((fv,Ol)=>{"use strict";var Bl=zr(),Qd=O().has,ep=O().isValidEntityCode,Pl=O().fromCodePoint,tp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,np=/^&([a-z][a-z0-9]{1,31});/i;Ol.exports=function(e,t){var i,r,o,s,a=e.pos,l=e.posMax;if(e.src.charCodeAt(a)!==38||a+1>=l)return!1;if(i=e.src.charCodeAt(a+1),i===35){if(o=e.src.slice(a).match(tp),o)return t||(r=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0),s.content=ep(r)?Pl(r):Pl(65533),s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0}else if(o=e.src.slice(a).match(np),o&&Qd(Bl,o[1]))return t||(s=e.push("text_special","",0),s.content=Bl[o[1]],s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0;return!1}});var Hl=E((mv,zl)=>{"use strict";function Rl(n,e){var t,i,r,o,s,a,l,c,u={},h=e.length;if(h){var d=0,p=-2,f=[];for(t=0;t<h;t++)if(r=e[t],f.push(0),(e[d].marker!==r.marker||p!==r.token-1)&&(d=t),p=r.token,r.length=r.length||0,!!r.close){for(u.hasOwnProperty(r.marker)||(u[r.marker]=[-1,-1,-1,-1,-1,-1]),s=u[r.marker][(r.open?3:0)+r.length%3],i=d-f[d]-1,a=i;i>s;i-=f[i]+1)if(o=e[i],o.marker===r.marker&&o.open&&o.end<0&&(l=!1,(o.close||r.open)&&(o.length+r.length)%3===0&&(o.length%3!==0||r.length%3!==0)&&(l=!0),!l)){c=i>0&&!e[i-1].open?f[i-1]+1:0,f[t]=t-i+c,f[i]=c,r.open=!1,o.end=t,o.close=!1,a=-1,p=-2;break}a!==-1&&(u[r.marker][(r.open?3:0)+(r.length||0)%3]=a)}}}zl.exports=function(e){var t,i=e.tokens_meta,r=e.tokens_meta.length;for(Rl(e,e.delimiters),t=0;t<r;t++)i[t]&&i[t].delimiters&&Rl(e,i[t].delimiters)}});var jl=E((gv,Ul)=>{"use strict";Ul.exports=function(e){var t,i,r=0,o=e.tokens,s=e.tokens.length;for(t=i=0;t<s;t++)o[t].nesting<0&&r--,o[t].level=r,o[t].nesting>0&&r++,o[t].type==="text"&&t+1<s&&o[t+1].type==="text"?o[t+1].content=o[t].content+o[t+1].content:(t!==i&&(o[i]=o[t]),i++);t!==i&&(o.length=i)}});var Kl=E((bv,Zl)=>{"use strict";var so=di(),Vl=O().isWhiteSpace,Wl=O().isPunctChar,Gl=O().isMdAsciiPunct;function Zt(n,e,t,i){this.src=n,this.env=t,this.md=e,this.tokens=i,this.tokens_meta=Array(i.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}Zt.prototype.pushPending=function(){var n=new so("text","",0);return n.content=this.pending,n.level=this.pendingLevel,this.tokens.push(n),this.pending="",n};Zt.prototype.push=function(n,e,t){this.pending&&this.pushPending();var i=new so(n,e,t),r=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),i.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(i),this.tokens_meta.push(r),i};Zt.prototype.scanDelims=function(n,e){var t=n,i,r,o,s,a,l,c,u,h,d=!0,p=!0,f=this.posMax,m=this.src.charCodeAt(n);for(i=n>0?this.src.charCodeAt(n-1):32;t<f&&this.src.charCodeAt(t)===m;)t++;return o=t-n,r=t<f?this.src.charCodeAt(t):32,c=Gl(i)||Wl(String.fromCharCode(i)),h=Gl(r)||Wl(String.fromCharCode(r)),l=Vl(i),u=Vl(r),u?d=!1:h&&(l||c||(d=!1)),l?p=!1:c&&(u||h||(p=!1)),e?(s=d,a=p):(s=d&&(!p||c),a=p&&(!d||h)),{can_open:s,can_close:a,length:o}};Zt.prototype.Token=so;Zl.exports=Zt});var Jl=E((vv,Yl)=>{"use strict";var Xl=ui(),ao=[["text",bl()],["linkify",yl()],["newline",xl()],["escape",Cl()],["backticks",El()],["strikethrough",to().tokenize],["emphasis",io().tokenize],["link",Tl()],["image",Il()],["autolink",Ml()],["html_inline",ql()],["entity",Nl()]],lo=[["balance_pairs",Hl()],["strikethrough",to().postProcess],["emphasis",io().postProcess],["fragments_join",jl()]];function Kt(){var n;for(this.ruler=new Xl,n=0;n<ao.length;n++)this.ruler.push(ao[n][0],ao[n][1]);for(this.ruler2=new Xl,n=0;n<lo.length;n++)this.ruler2.push(lo[n][0],lo[n][1])}Kt.prototype.skipToken=function(n){var e,t,i=n.pos,r=this.ruler.getRules(""),o=r.length,s=n.md.options.maxNesting,a=n.cache;if(typeof a[i]<"u"){n.pos=a[i];return}if(n.level<s)for(t=0;t<o&&(n.level++,e=r[t](n,!0),n.level--,!e);t++);else n.pos=n.posMax;e||n.pos++,a[i]=n.pos};Kt.prototype.tokenize=function(n){for(var e,t,i=this.ruler.getRules(""),r=i.length,o=n.posMax,s=n.md.options.maxNesting;n.pos<o;){if(n.level<s)for(t=0;t<r&&(e=i[t](n,!1),!e);t++);if(e){if(n.pos>=o)break;continue}n.pending+=n.src[n.pos++]}n.pending&&n.pushPending()};Kt.prototype.parse=function(n,e,t,i){var r,o,s,a=new this.State(n,e,t,i);for(this.tokenize(a),o=this.ruler2.getRules(""),s=o.length,r=0;r<s;r++)o[r](a)};Kt.prototype.State=Kl();Yl.exports=Kt});var ec=E((yv,Ql)=>{"use strict";Ql.exports=function(n){var e={};n=n||{},e.src_Any=Ur().source,e.src_Cc=jr().source,e.src_Z=Vr().source,e.src_P=oi().source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");var t="[><\uFF5C]";return e.src_pseudo_letter="(?:(?!"+t+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+t+"|"+e.src_ZPCc+")(?!"+(n["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+t+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(n["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+t+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}});var oc=E((wv,rc)=>{"use strict";function co(n){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(i){n[i]=t[i]})}),n}function vi(n){return Object.prototype.toString.call(n)}function ip(n){return vi(n)==="[object String]"}function rp(n){return vi(n)==="[object Object]"}function op(n){return vi(n)==="[object RegExp]"}function tc(n){return vi(n)==="[object Function]"}function sp(n){return n.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var ic={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function ap(n){return Object.keys(n||{}).reduce(function(e,t){return e||ic.hasOwnProperty(t)},!1)}var lp={"http:":{validate:function(n,e,t){var i=n.slice(e);return t.re.http||(t.re.http=new RegExp("^\\/\\/"+t.re.src_auth+t.re.src_host_port_strict+t.re.src_path,"i")),t.re.http.test(i)?i.match(t.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(n,e,t){var i=n.slice(e);return t.re.no_http||(t.re.no_http=new RegExp("^"+t.re.src_auth+"(?:localhost|(?:(?:"+t.re.src_domain+")\\.)+"+t.re.src_domain_root+")"+t.re.src_port+t.re.src_host_terminator+t.re.src_path,"i")),t.re.no_http.test(i)?e>=3&&n[e-3]===":"||e>=3&&n[e-3]==="/"?0:i.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(n,e,t){var i=n.slice(e);return t.re.mailto||(t.re.mailto=new RegExp("^"+t.re.src_email_name+"@"+t.re.src_host_strict,"i")),t.re.mailto.test(i)?i.match(t.re.mailto)[0].length:0}}},cp="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",up="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function hp(n){n.__index__=-1,n.__text_cache__=""}function dp(n){return function(e,t){var i=e.slice(t);return n.test(i)?i.match(n)[0].length:0}}function nc(){return function(n,e){e.normalize(n)}}function bi(n){var e=n.re=ec()(n.__opts__),t=n.__tlds__.slice();n.onCompile(),n.__tlds_replaced__||t.push(cp),t.push(e.src_xn),e.src_tlds=t.join("|");function i(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(i(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(i(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(i(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(i(e.tpl_host_fuzzy_test),"i");var r=[];n.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(n.__schemas__).forEach(function(a){var l=n.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(n.__compiled__[a]=c,rp(l)){op(l.validate)?c.validate=dp(l.validate):tc(l.validate)?c.validate=l.validate:o(a,l),tc(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=nc();return}if(ip(l)){r.push(a);return}o(a,l)}}),r.forEach(function(a){n.__compiled__[n.__schemas__[a]]&&(n.__compiled__[a].validate=n.__compiled__[n.__schemas__[a]].validate,n.__compiled__[a].normalize=n.__compiled__[n.__schemas__[a]].normalize)}),n.__compiled__[""]={validate:null,normalize:nc()};var s=Object.keys(n.__compiled__).filter(function(a){return a.length>0&&n.__compiled__[a]}).map(sp).join("|");n.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","i"),n.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","ig"),n.re.schema_at_start=RegExp("^"+n.re.schema_search.source,"i"),n.re.pretest=RegExp("("+n.re.schema_test.source+")|("+n.re.host_fuzzy_test.source+")|@","i"),hp(n)}function pp(n,e){var t=n.__index__,i=n.__last_index__,r=n.__text_cache__.slice(t,i);this.schema=n.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=i+e,this.raw=r,this.text=r,this.url=r}function uo(n,e){var t=new pp(n,e);return n.__compiled__[t.schema].normalize(t,n),t}function me(n,e){if(!(this instanceof me))return new me(n,e);e||ap(n)&&(e=n,n={}),this.__opts__=co({},ic,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=co({},lp,n),this.__compiled__={},this.__tlds__=up,this.__tlds_replaced__=!1,this.re={},bi(this)}me.prototype.add=function(e,t){return this.__schemas__[e]=t,bi(this),this};me.prototype.set=function(e){return this.__opts__=co(this.__opts__,e),this};me.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,i,r,o,s,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(o=this.testSchemaAt(e,t[2],l.lastIndex),o){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(i=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=i.index+i[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=i.index+i[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(r=e.match(this.re.email_fuzzy))!==null&&(s=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};me.prototype.pretest=function(e){return this.re.pretest.test(e)};me.prototype.testSchemaAt=function(e,t,i){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,i,this):0};me.prototype.match=function(e){var t=0,i=[];this.__index__>=0&&this.__text_cache__===e&&(i.push(uo(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)i.push(uo(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return i.length?i:null};me.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;var t=this.re.schema_at_start.exec(e);if(!t)return null;var i=this.testSchemaAt(e,t[2],t[0].length);return i?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i,uo(this,0)):null};me.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(i,r,o){return i!==o[r-1]}).reverse(),bi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,bi(this),this)};me.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};me.prototype.onCompile=function(){};rc.exports=me});var pc={};_t(pc,{decode:()=>mo,default:()=>xp,encode:()=>go,toASCII:()=>dc,toUnicode:()=>hc,ucs2decode:()=>fo,ucs2encode:()=>cc});function Ve(n){throw new RangeError(bp[n])}function vp(n,e){let t=[],i=n.length;for(;i--;)t[i]=e(n[i]);return t}function lc(n,e){let t=n.split("@"),i="";t.length>1&&(i=t[0]+"@",n=t[1]),n=n.replace(gp,".");let r=n.split("."),o=vp(r,e).join(".");return i+o}function fo(n){let e=[],t=0,i=n.length;for(;t<i;){let r=n.charCodeAt(t++);if(r>=55296&&r<=56319&&t<i){let o=n.charCodeAt(t++);(o&64512)==56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e}var ac,fp,mp,gp,bp,ho,Te,po,cc,yp,sc,uc,mo,go,hc,dc,wp,xp,fc=_u(()=>{"use strict";ac="-",fp=/^xn--/,mp=/[^\0-\x7F]/,gp=/[\x2E\u3002\uFF0E\uFF61]/g,bp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},ho=36-1,Te=Math.floor,po=String.fromCharCode;cc=n=>String.fromCodePoint(...n),yp=function(n){return n>=48&&n<58?26+(n-48):n>=65&&n<91?n-65:n>=97&&n<123?n-97:36},sc=function(n,e){return n+22+75*(n<26)-((e!=0)<<5)},uc=function(n,e,t){let i=0;for(n=t?Te(n/700):n>>1,n+=Te(n/e);n>ho*26>>1;i+=36)n=Te(n/ho);return Te(i+(ho+1)*n/(n+38))},mo=function(n){let e=[],t=n.length,i=0,r=128,o=72,s=n.lastIndexOf(ac);s<0&&(s=0);for(let a=0;a<s;++a)n.charCodeAt(a)>=128&&Ve("not-basic"),e.push(n.charCodeAt(a));for(let a=s>0?s+1:0;a<t;){let l=i;for(let u=1,h=36;;h+=36){a>=t&&Ve("invalid-input");let d=yp(n.charCodeAt(a++));d>=36&&Ve("invalid-input"),d>Te((2147483647-i)/u)&&Ve("overflow"),i+=d*u;let p=h<=o?1:h>=o+26?26:h-o;if(d<p)break;let f=36-p;u>Te(2147483647/f)&&Ve("overflow"),u*=f}let c=e.length+1;o=uc(i-l,c,l==0),Te(i/c)>2147483647-r&&Ve("overflow"),r+=Te(i/c),i%=c,e.splice(i++,0,r)}return String.fromCodePoint(...e)},go=function(n){let e=[];n=fo(n);let t=n.length,i=128,r=0,o=72;for(let l of n)l<128&&e.push(po(l));let s=e.length,a=s;for(s&&e.push(ac);a<t;){let l=2147483647;for(let u of n)u>=i&&u<l&&(l=u);let c=a+1;l-i>Te((2147483647-r)/c)&&Ve("overflow"),r+=(l-i)*c,i=l;for(let u of n)if(u<i&&++r>2147483647&&Ve("overflow"),u===i){let h=r;for(let d=36;;d+=36){let p=d<=o?1:d>=o+26?26:d-o;if(h<p)break;let f=h-p,m=36-p;e.push(po(sc(p+f%m,0))),h=Te(f/m)}e.push(po(sc(h,0))),o=uc(r,c,a===s),r=0,++a}++r,++i}return e.join("")},hc=function(n){return lc(n,function(e){return fp.test(e)?mo(e.slice(4).toLowerCase()):e})},dc=function(n){return lc(n,function(e){return mp.test(e)?"xn--"+go(e):e})},wp={version:"2.1.0",ucs2:{decode:fo,encode:cc},decode:mo,encode:go,toASCII:dc,toUnicode:hc},xp=wp});var gc=E((xv,mc)=>{"use strict";mc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}});var vc=E((kv,bc)=>{"use strict";bc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}}});var wc=E((Cv,yc)=>{"use strict";yc.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}});var _c=E((_v,Cc)=>{"use strict";var Xt=O(),kp=ia(),Cp=oa(),_p=$a(),Ep=ml(),Sp=Jl(),Ap=oc(),Qe=Hr(),xc=(fc(),Eu(pc)),Dp={default:gc(),zero:vc(),commonmark:wc()},Tp=/^(vbscript|javascript|file|data):/,Lp=/^data:image\/(gif|png|jpeg|webp);/;function Ip(n){var e=n.trim().toLowerCase();return Tp.test(e)?!!Lp.test(e):!0}var kc=["http:","https:","mailto:"];function $p(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||kc.indexOf(e.protocol)>=0))try{e.hostname=xc.toASCII(e.hostname)}catch{}return Qe.encode(Qe.format(e))}function Mp(n){var e=Qe.parse(n,!0);if(e.hostname&&(!e.protocol||kc.indexOf(e.protocol)>=0))try{e.hostname=xc.toUnicode(e.hostname)}catch{}return Qe.decode(Qe.format(e),Qe.decode.defaultChars+"%")}function be(n,e){if(!(this instanceof be))return new be(n,e);e||Xt.isString(n)||(e=n||{},n="default"),this.inline=new Sp,this.block=new Ep,this.core=new _p,this.renderer=new Cp,this.linkify=new Ap,this.validateLink=Ip,this.normalizeLink=$p,this.normalizeLinkText=Mp,this.utils=Xt,this.helpers=Xt.assign({},kp),this.options={},this.configure(n),e&&this.set(e)}be.prototype.set=function(n){return Xt.assign(this.options,n),this};be.prototype.configure=function(n){var e=this,t;if(Xt.isString(n)&&(t=n,n=Dp[t],!n))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!n)throw new Error("Wrong `markdown-it` preset, can't be empty");return n.options&&e.set(n.options),n.components&&Object.keys(n.components).forEach(function(i){n.components[i].rules&&e[i].ruler.enableOnly(n.components[i].rules),n.components[i].rules2&&e[i].ruler2.enableOnly(n.components[i].rules2)}),this};be.prototype.enable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.enable(n,!0))},this),t=t.concat(this.inline.ruler2.enable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+i);return this};be.prototype.disable=function(n,e){var t=[];Array.isArray(n)||(n=[n]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.disable(n,!0))},this),t=t.concat(this.inline.ruler2.disable(n,!0));var i=n.filter(function(r){return t.indexOf(r)<0});if(i.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+i);return this};be.prototype.use=function(n){var e=[this].concat(Array.prototype.slice.call(arguments,1));return n.apply(n,e),this};be.prototype.parse=function(n,e){if(typeof n!="string")throw new Error("Input data should be a String");var t=new this.core.State(n,this,e);return this.core.process(t),t.tokens};be.prototype.render=function(n,e){return e=e||{},this.renderer.render(this.parse(n,e),this.options,e)};be.prototype.parseInline=function(n,e){var t=new this.core.State(n,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};be.prototype.renderInline=function(n,e){return e=e||{},this.renderer.render(this.parseInline(n,e),this.options,e)};Cc.exports=be});var Sc=E((Ev,Ec)=>{"use strict";Ec.exports=_c()});var Ic=E((Sv,Lc)=>{var bo=!0,Dc=!1,Tc=!1;Lc.exports=function(n,e){e&&(bo=!e.enabled,Dc=!!e.label,Tc=!!e.labelAfter),n.core.ruler.after("inline","github-task-lists",function(t){for(var i=t.tokens,r=2;r<i.length;r++)qp(i,r)&&(Bp(i[r],t.Token),Ac(i[r-2],"class","task-list-item"+(bo?"":" enabled")),Ac(i[Fp(i,r-2)],"class","contains-task-list"))})};function Ac(n,e,t){var i=n.attrIndex(e),r=[e,t];i<0?n.attrPush(r):n.attrs[i]=r}function Fp(n,e){for(var t=n[e].level-1,i=e-1;i>=0;i--)if(n[i].level===t)return i;return-1}function qp(n,e){return zp(n[e])&&Hp(n[e-1])&&Up(n[e-2])&&jp(n[e])}function Bp(n,e){if(n.children.unshift(Pp(n,e)),n.children[1].content=n.children[1].content.slice(3),n.content=n.content.slice(3),Dc)if(Tc){n.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);n.children[0].content=n.children[0].content.slice(0,-1)+' id="'+t+'">',n.children.push(Rp(n.content,t,e))}else n.children.unshift(Op(e)),n.children.push(Np(e))}function Pp(n,e){var t=new e("html_inline","",0),i=bo?' disabled="" ':"";return n.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+i+'type="checkbox">':(n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+i+'type="checkbox">'),t}function Op(n){var e=new n("html_inline","",0);return e.content="<label>",e}function Np(n){var e=new n("html_inline","",0);return e.content="</label>",e}function Rp(n,e,t){var i=new t("html_inline","",0);return i.content='<label class="task-list-item-label" for="'+e+'">'+n+"</label>",i.attrs=[{for:e}],i}function zp(n){return n.type==="inline"}function Hp(n){return n.type==="paragraph_open"}function Up(n){return n.type==="list_item_open"}function jp(n){return n.content.indexOf("[ ] ")===0||n.content.indexOf("[x] ")===0||n.content.indexOf("[X] ")===0}});var cr={};_t(cr,{emit:()=>ar,emitPublic:()=>Tu,error:()=>lr,listen:()=>Du,showResponseError:()=>$u,showValidationErrors:()=>Iu,success:()=>Lu});var rn={},Au=[];function ar(n,e){Au.push({name:n,data:e});let t=rn[n]||[];for(let i of t)i(e)}function Du(n,e){typeof rn[n]>"u"&&(rn[n]=[]),rn[n].push(e)}function Tu(n,e,t){let i=new CustomEvent(e,{detail:t,bubbles:!0});n.dispatchEvent(i)}function Lu(n){ar("success",n)}function lr(n){ar("error",n)}function Iu(n){if(n.status&&n.status===422&&n.data){let e=Object.values(n.data).flat().join(`
-`);lr(e)}}function $u(n){n.status&&n.status>=400&&n.data&&n.data.message&&lr(n.data.message)}var ur={};_t(ur,{HttpError:()=>on,createXMLHttpRequest:()=>Fu,delete:()=>Nu,get:()=>qu,patch:()=>Ou,post:()=>Bu,put:()=>Pu});async function Mu(n){if(n.status===204)return null;let t=(n.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?n.json():n.text()}var on=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Fu(n,e,t={}){let i=document.querySelector("meta[name=token]").getAttribute("content"),r=new XMLHttpRequest;for(let[o,s]of Object.entries(t))r.addEventListener(o,s.bind(r));return r.open(n,e),r.withCredentials=!0,r.setRequestHeader("X-CSRF-TOKEN",i),r}async function Po(n,e={}){let t=n;if(t.startsWith("http")||(t=window.baseUrl(t)),e.params){let l=new URL(t);for(let c of Object.keys(e.params)){let u=e.params[c];typeof u<"u"&&u!==null&&l.searchParams.set(c,u)}t=l.toString()}let i=document.querySelector("meta[name=token]").getAttribute("content"),r={...e,credentials:"same-origin"};r.headers={...r.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":i};let o=await fetch(t,r),s=await Mu(o),a={data:s,headers:o.headers,redirected:o.redirected,status:o.status,statusText:o.statusText,url:o.url,original:o};if(!o.ok)throw new on(o,s);return a}async function sn(n,e,t=null){let i={method:n,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(i.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},i.body=JSON.stringify(t)),t instanceof FormData&&n!=="post"&&(t.append("_method",n),i.method="post"),Po(e,i)}async function qu(n,e={}){return Po(n,{method:"GET",params:e})}async function Bu(n,e=null){return sn("POST",n,e)}async function Pu(n,e=null){return sn("PUT",n,e)}async function Ou(n,e=null){return sn("PATCH",n,e)}async function Nu(n,e=null){return sn("DELETE",n,e)}var hr=class{constructor(){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let i=t.getAttribute("key"),r=t.getAttribute("value");this.store.set(i,r)}}get(e,t){let i=this.getTransText(e);return this.performReplacements(i,t)}getPlural(e,t,i){let r=this.getTransText(e);return this.parsePlural(r,t,i)}parsePlural(e,t,i){let r=e.split("|"),o=/^{([0-9]+)}/,s=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of r){let c=l.match(o);if(c!==null&&Number(c[1])===t){a=l.replace(o,"").trim();break}let u=l.match(s);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(s,"").trim();break}}return a===null&&r.length>1&&(a=t===1?r[0]:r[1]),a===null&&(a=r[0]),this.performReplacements(a,i)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let i=e.match(/:(\S+)/g);if(i===null)return e;let r=e;return i.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(r=r.replace(o,t[s]))}),r}},Oo=hr;var gr={};_t(gr,{first:()=>Uu,firstOnElement:()=>Vu,get:()=>ju,init:()=>fr,register:()=>mr});function dr(n){let e=i=>i.slice(0,1).toUpperCase()+i.slice(1),t=n.split("-");return t[0]+t.slice(1).map(e).join("")}function No(n){return n.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var Et={},Ro={},pr=new WeakMap;function Ru(n,e){let t={},i={},r=`${n}@`,o=`[refs*="${r}"]`,s=[...e.querySelectorAll(o)];e.matches(o)&&s.push(e);for(let a of s){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(r)).map(c=>c.replace(r,"")).map(dr);for(let c of l)t[c]=a,typeof i[c]>"u"&&(i[c]=[]),i[c].push(a)}return{refs:t,manyRefs:i}}function zu(n,e){let t={},i=`option:${n}:`;for(let{name:r,value:o}of e.attributes)if(r.startsWith(i)){let s=r.replace(i,"");t[dr(s)]=o||""}return t}function Hu(n,e){let t=Ro[n];if(t===void 0)return;let i;try{i=new t,i.$name=n,i.$el=e;let o=Ru(n,e);i.$refs=o.refs,i.$manyRefs=o.manyRefs,i.$opts=zu(n,e),i.setup()}catch(o){console.error("Failed to create component",o,n,e)}typeof Et[n]>"u"&&(Et[n]=[]),Et[n].push(i);let r=pr.get(e)||{};r[n]=i,pr.set(e,r)}function fr(n=document){let e=n.querySelectorAll("[component],[components]");for(let t of e){let i=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let r of i)Hu(r,t)}}function mr(n){let e=Object.keys(n);for(let t of e)Ro[No(t)]=n[t]}function Uu(n){return(Et[n]||[null])[0]}function ju(n){return Et[n]||[]}function Vu(n,e){return(pr.get(n)||{})[e]||null}var Mo={};_t(Mo,{AddRemoveRows:()=>cn,AjaxDeleteRow:()=>un,AjaxForm:()=>hn,Attachments:()=>dn,AttachmentsList:()=>pn,AutoSubmit:()=>mn,AutoSuggest:()=>fn,BackToTop:()=>gn,BookSort:()=>Fn,ChapterContents:()=>Bn,CodeEditor:()=>Pn,CodeHighlighter:()=>On,CodeTextarea:()=>Nn,Collapsible:()=>Rn,ConfirmDialog:()=>zn,CustomCheckbox:()=>Hn,DetailsHighlighter:()=>Un,Dropdown:()=>jn,DropdownSearch:()=>Vn,Dropzone:()=>Wn,EditorToolbox:()=>Gn,EntityPermissions:()=>Zn,EntitySearch:()=>Kn,EntitySelector:()=>Xn,EntitySelectorPopup:()=>Yn,EventEmitSelect:()=>Jn,ExpandToggle:()=>Qn,GlobalSearch:()=>ei,HeaderMobileToggle:()=>ti,ImageManager:()=>ni,ImagePicker:()=>ii,ListSortControl:()=>ri,MarkdownEditor:()=>Ii,NewUserPassword:()=>$i,Notification:()=>Mi,OptionalInput:()=>Fi,PageComments:()=>qi,PageDisplay:()=>Bi,PageEditor:()=>Pi,PagePicker:()=>Ni,PermissionsTable:()=>Ri,Pointer:()=>zi,Popup:()=>Hi,SettingAppColorScheme:()=>Ui,SettingColorPicker:()=>ji,SettingHomepageControl:()=>Vi,ShelfSort:()=>Wi,ShortcutInput:()=>Zi,Shortcuts:()=>Gi,SortableList:()=>Ki,SubmitOnChange:()=>Xi,Tabs:()=>Yi,TagManager:()=>Ji,TemplateManager:()=>Qi,ToggleSwitch:()=>er,TriLayout:()=>tr,UserSelect:()=>nr,WebhookEvents:()=>ir,WysiwygEditor:()=>sr});function _e(n,e={},t=[]){let i=document.createElement(n);for(let[r,o]of Object.entries(e))o===null?i.removeAttribute(r):i.setAttribute(r,o);for(let r of t)typeof r=="string"?i.append(document.createTextNode(r)):i.append(r);return i}function br(n,e){let t=document.querySelectorAll(n);for(let i of t)e(i)}function an(n,e,t){for(let i of e)n.addEventListener(i,t)}function N(n,e){Array.isArray(n)||(n=[n]);for(let t of n)t.addEventListener("click",e),t.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),e(i))})}function ln(n,e){Array.isArray(n)||(n=[n]);let t=i=>{i.key==="Enter"&&e(i)};n.forEach(i=>i.addEventListener("keypress",t))}function W(n,e,t,i){n.addEventListener(t,r=>{let o=r.target.closest(e);o&&i.call(o,r,o)})}function zo(n,e){let t=document.querySelectorAll(n);e=e.toLowerCase();for(let i of t)if(i.textContent.toLowerCase().includes(e))return i;return null}function St(n){n.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Ho(){let n=document.createElement("div");return n.classList.add("loading-container"),n.innerHTML="<div></div><div></div><div></div>",n}function At(n){let e=n.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ne(n){let e=document.createElement("div");return e.innerHTML=n,window.$components.init(e),e.children[0]}function Re(n,e,t){let i;return function(...o){let s=this,a=function(){i=null,t||n.apply(s,o)},l=t&&!i;clearTimeout(i),i=setTimeout(a,e),l&&n.apply(s,o)}}function Dt(n){if(!n)return;n.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(n).getPropertyValue("background-color");n.style.backgroundColor=e,setTimeout(()=>{n.classList.add("selectFade"),n.style.backgroundColor=t},10),setTimeout(()=>{n.classList.remove("selectFade"),n.style.backgroundColor=""},3e3)}function Uo(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jo(){let n=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${n()+n()}-${n()}-${n()}-${n()}-${n()}${n()}${n()}`}var b=class{constructor(){se(this,"$name","");se(this,"$el",null);se(this,"$refs",{});se(this,"$manyRefs",{});se(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let i=this.$name,r=new CustomEvent(`${i}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(r)}};var cn=class extends b{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),W(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.$components.init(e)}setClonedInputNames(e){let t=jo(),i=e.querySelectorAll('[name*="randrowid"]');for(let r of i)r.name=r.name.split("randrowid").join(t)}};var un=class extends b{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,N(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(()=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var hn=class extends b{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}ln(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>N(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let i of t)e.append(i.getAttribute("name"),i.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var dn=class extends b{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.linksContainer=this.$refs.linksContainer,this.listPanel=this.$refs.listPanel,this.attachLinkButton=this.$refs.attachLinkButton,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let i=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),r=JSON.parse(i);window.$events.emit("editor::insert",{html:r["text/html"],markdown:r["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(e){let t={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[i,r]of Object.entries(t))r.toggleAttribute("hidden",i!==e)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.listPanel.innerHTML=e.data,window.$components.init(this.listPanel)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.showSection("edit"),St(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var pn=class extends b{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href+="?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var Tt,yr,Lt,wr,ze=class{constructor(e,t=null,i=null){re(this,Tt);re(this,Lt);this.containers=[e],this.onEscape=t,this.onEnter=i,e.addEventListener("keydown",T(this,Tt,yr).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",T(this,Tt,yr).bind(this))}focusNext(){let e=T(this,Lt,wr).call(this),i=e.indexOf(document.activeElement)+1;i>=e.length&&(i=0),e[i].focus()}focusPrevious(){let e=T(this,Lt,wr).call(this),i=e.indexOf(document.activeElement)-1;i<0&&(i=e.length-1),e[i].focus()}};Tt=new WeakSet,yr=function(e){e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))},Lt=new WeakSet,wr=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let i of this.containers)e.push(...i.querySelectorAll(t));return e};var xr={},fn=class extends b{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){new ze(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault(),this.selectSuggestion(t.target.textContent)}).shareHandlingToEl(this.input),W(this.list,".text-item","click",(t,i)=>{this.selectSuggestion(i.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",t=>{t.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(e){this.input.value=e,this.lastPopulated=Date.now(),this.input.focus(),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hideSuggestions()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),r=(await this.loadSuggestions(t,e)).filter(o=>t===""||o.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(r)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let i={search:e,name:t},r=`${this.url}:${JSON.stringify(i)}`;if(xr[r])return xr[r];let o=await window.$http.get(this.url,i);return xr[r]=o.data,o.data}displaySuggestions(e){if(e.length===0){this.hideSuggestions();return}this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${Uo(t)}</div></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll(".text-item"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var mn=class extends b{setup(){this.form=this.$el,this.form.submit()}};var gn=class extends b{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,i=300,r=Date.now(),o=this.targetElem.getBoundingClientRect().top;function s(){let a=1-(Date.now()-r)/i,l=Math.abs(a*o);a>0?(t.scrollTop=l,requestAnimationFrame(s.bind(this))):t.scrollTop=e}requestAnimationFrame(s.bind(this))}};function Vo(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Se(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Vo(Object(t),!0).forEach(function(i){Wu(n,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Vo(Object(t)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(t,i))})}return n}function Cn(n){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Cn=function(e){return typeof e}:Cn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cn(n)}function Wu(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ke(){return ke=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ke.apply(this,arguments)}function Gu(n,e){if(n==null)return{};var t={},i=Object.keys(n),r,o;for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&(t[r]=n[r]);return t}function Zu(n,e){if(n==null)return{};var t=Gu(n,e),i,r;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)i=o[r],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function Ku(n){return Xu(n)||Yu(n)||Ju(n)||Qu()}function Xu(n){if(Array.isArray(n))return $r(n)}function Yu(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Ju(n,e){if(n){if(typeof n=="string")return $r(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return $r(n,e)}}function $r(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=n[t];return i}function Qu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
-In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var eh="1.15.0";function Ie(n){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(n)}var $e=Ie(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Ut=Ie(/Edge/i),Wo=Ie(/firefox/i),Ot=Ie(/safari/i)&&!Ie(/chrome/i)&&!Ie(/android/i),ns=Ie(/iP(ad|od|hone)/i),is=Ie(/chrome/i)&&Ie(/android/i),rs={capture:!1,passive:!1};function P(n,e,t){n.addEventListener(e,t,!$e&&rs)}function B(n,e,t){n.removeEventListener(e,t,!$e&&rs)}function Dn(n,e){if(e){if(e[0]===">"&&(e=e.substring(1)),n)try{if(n.matches)return n.matches(e);if(n.msMatchesSelector)return n.msMatchesSelector(e);if(n.webkitMatchesSelector)return n.webkitMatchesSelector(e)}catch{return!1}return!1}}function th(n){return n.host&&n!==document&&n.host.nodeType?n.host:n.parentNode}function xe(n,e,t,i){if(n){t=t||document;do{if(e!=null&&(e[0]===">"?n.parentNode===t&&Dn(n,e):Dn(n,e))||i&&n===t)return n;if(n===t)break}while(n=th(n))}return null}var Go=/\s+/g;function X(n,e,t){if(n&&e)if(n.classList)n.classList[t?"add":"remove"](e);else{var i=(" "+n.className+" ").replace(Go," ").replace(" "+e+" "," ");n.className=(i+(t?" "+e:"")).replace(Go," ")}}function A(n,e,t){var i=n&&n.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(n,""):n.currentStyle&&(t=n.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function Xe(n,e){var t="";if(typeof n=="string")t=n;else do{var i=A(n,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(n=n.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function os(n,e,t){if(n){var i=n.getElementsByTagName(e),r=0,o=i.length;if(t)for(;r<o;r++)t(i[r],r);return i}return[]}function Ee(){var n=document.scrollingElement;return n||document.documentElement}function j(n,e,t,i,r){if(!(!n.getBoundingClientRect&&n!==window)){var o,s,a,l,c,u,h;if(n!==window&&n.parentNode&&n!==Ee()?(o=n.getBoundingClientRect(),s=o.top,a=o.left,l=o.bottom,c=o.right,u=o.height,h=o.width):(s=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||t)&&n!==window&&(r=r||n.parentNode,!$e))do if(r&&r.getBoundingClientRect&&(A(r,"transform")!=="none"||t&&A(r,"position")!=="static")){var d=r.getBoundingClientRect();s-=d.top+parseInt(A(r,"border-top-width")),a-=d.left+parseInt(A(r,"border-left-width")),l=s+o.height,c=a+o.width;break}while(r=r.parentNode);if(i&&n!==window){var p=Xe(r||n),f=p&&p.a,m=p&&p.d;p&&(s/=m,a/=f,h/=f,u/=m,l=s+u,c=a+h)}return{top:s,left:a,bottom:l,right:c,width:h,height:u}}}function Zo(n,e,t){for(var i=je(n,!0),r=j(n)[e];i;){var o=j(i)[t],s=void 0;if(t==="top"||t==="left"?s=r>=o:s=r<=o,!s)return i;if(i===Ee())break;i=je(i,!1)}return!1}function ht(n,e,t,i){for(var r=0,o=0,s=n.children;o<s.length;){if(s[o].style.display!=="none"&&s[o]!==$.ghost&&(i||s[o]!==$.dragged)&&xe(s[o],t.draggable,n,!1)){if(r===e)return s[o];r++}o++}return null}function Pr(n,e){for(var t=n.lastElementChild;t&&(t===$.ghost||A(t,"display")==="none"||e&&!Dn(t,e));)t=t.previousElementSibling;return t||null}function Y(n,e){var t=0;if(!n||!n.parentNode)return-1;for(;n=n.previousElementSibling;)n.nodeName.toUpperCase()!=="TEMPLATE"&&n!==$.clone&&(!e||Dn(n,e))&&t++;return t}function Ko(n){var e=0,t=0,i=Ee();if(n)do{var r=Xe(n),o=r.a,s=r.d;e+=n.scrollLeft*o,t+=n.scrollTop*s}while(n!==i&&(n=n.parentNode));return[e,t]}function nh(n,e){for(var t in n)if(n.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===n[t][i])return Number(t)}return-1}function je(n,e){if(!n||!n.getBoundingClientRect)return Ee();var t=n,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=A(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Ee();if(i||e)return t;i=!0}}while(t=t.parentNode);return Ee()}function ih(n,e){if(n&&e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function kr(n,e){return Math.round(n.top)===Math.round(e.top)&&Math.round(n.left)===Math.round(e.left)&&Math.round(n.height)===Math.round(e.height)&&Math.round(n.width)===Math.round(e.width)}var Nt;function ss(n,e){return function(){if(!Nt){var t=arguments,i=this;t.length===1?n.call(i,t[0]):n.apply(i,t),Nt=setTimeout(function(){Nt=void 0},e)}}}function rh(){clearTimeout(Nt),Nt=void 0}function as(n,e,t){n.scrollLeft+=e,n.scrollTop+=t}function Or(n){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(n).cloneNode(!0):t?t(n).clone(!0)[0]:n.cloneNode(!0)}function Xo(n,e){A(n,"position","absolute"),A(n,"top",e.top),A(n,"left",e.left),A(n,"width",e.width),A(n,"height",e.height)}function Cr(n){A(n,"position",""),A(n,"top",""),A(n,"left",""),A(n,"width",""),A(n,"height","")}var ne="Sortable"+new Date().getTime();function oh(){var n=[],e;return{captureAnimationState:function(){if(n=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(r){if(!(A(r,"display")==="none"||r===$.ghost)){n.push({target:r,rect:j(r)});var o=Se({},n[n.length-1].rect);if(r.thisAnimationDuration){var s=Xe(r,!0);s&&(o.top-=s.f,o.left-=s.e)}r.fromRect=o}})}},addAnimationState:function(i){n.push(i)},removeAnimationState:function(i){n.splice(nh(n,{target:i}),1)},animateAll:function(i){var r=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,s=0;n.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=j(c),d=c.prevFromRect,p=c.prevToRect,f=a.rect,m=Xe(c,!0);m&&(h.top-=m.f,h.left-=m.e),c.toRect=h,c.thisAnimationDuration&&kr(d,h)&&!kr(u,h)&&(f.top-h.top)/(f.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=ah(f,d,p,r.options)),kr(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=r.options.animation),r.animate(c,f,h,l)),l&&(o=!0,s=Math.max(s,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),o?e=setTimeout(function(){typeof i=="function"&&i()},s):typeof i=="function"&&i(),n=[]},animate:function(i,r,o,s){if(s){A(i,"transition",""),A(i,"transform","");var a=Xe(this.el),l=a&&a.a,c=a&&a.d,u=(r.left-o.left)/(l||1),h=(r.top-o.top)/(c||1);i.animatingX=!!u,i.animatingY=!!h,A(i,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=sh(i),A(i,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:"")),A(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){A(i,"transition",""),A(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},s)}}}}function sh(n){return n.offsetWidth}function ah(n,e,t,i){return Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var st=[],_r={initializeByDefault:!0},jt={mount:function(e){for(var t in _r)_r.hasOwnProperty(t)&&!(t in e)&&(e[t]=_r[t]);st.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),st.push(e)},pluginEvent:function(e,t,i){var r=this;this.eventCanceled=!1,i.cancel=function(){r.eventCanceled=!0};var o=e+"Global";st.forEach(function(s){t[s.pluginName]&&(t[s.pluginName][o]&&t[s.pluginName][o](Se({sortable:t},i)),t.options[s.pluginName]&&t[s.pluginName][e]&&t[s.pluginName][e](Se({sortable:t},i)))})},initializePlugins:function(e,t,i,r){st.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ke(i,c.defaults)}});for(var o in e.options)if(e.options.hasOwnProperty(o)){var s=this.modifyOption(e,o,e.options[o]);typeof s<"u"&&(e.options[o]=s)}},getEventProperties:function(e,t){var i={};return st.forEach(function(r){typeof r.eventProperties=="function"&&ke(i,r.eventProperties.call(t[r.pluginName],e))}),i},modifyOption:function(e,t,i){var r;return st.forEach(function(o){e[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[t]=="function"&&(r=o.optionListeners[t].call(e[o.pluginName],i))}),r}};function Ft(n){var e=n.sortable,t=n.rootEl,i=n.name,r=n.targetEl,o=n.cloneEl,s=n.toEl,a=n.fromEl,l=n.oldIndex,c=n.newIndex,u=n.oldDraggableIndex,h=n.newDraggableIndex,d=n.originalEvent,p=n.putSortable,f=n.extraEventProperties;if(e=e||t&&t[ne],!!e){var m,w=e.options,v="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!$e&&!Ut?m=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(i,!0,!0)),m.to=s||t,m.from=a||t,m.item=r||t,m.clone=o,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=u,m.newDraggableIndex=h,m.originalEvent=d,m.pullMode=p?p.lastPutMode:void 0;var g=Se(Se({},f),jt.getEventProperties(i,e));for(var k in g)m[k]=g[k];t&&t.dispatchEvent(m),w[v]&&w[v].call(e,m)}}var lh=["evt"],ae=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=i.evt,o=Zu(i,lh);jt.pluginEvent.bind($)(e,t,Se({dragEl:C,parentEl:Z,ghostEl:F,rootEl:U,nextEl:Ke,lastDownEl:_n,cloneEl:G,cloneHidden:Ue,dragStarted:qt,putSortable:Q,activeSortable:$.active,originalEvent:r,oldIndex:ut,oldDraggableIndex:Rt,newIndex:fe,newDraggableIndex:He,hideGhostForTarget:hs,unhideGhostForTarget:ds,cloneNowHidden:function(){Ue=!0},cloneNowShown:function(){Ue=!1},dispatchSortableEvent:function(a){oe({sortable:t,name:a,originalEvent:r})}},o))};function oe(n){Ft(Se({putSortable:Q,cloneEl:G,targetEl:C,rootEl:U,oldIndex:ut,oldDraggableIndex:Rt,newIndex:fe,newDraggableIndex:He},n))}var C,Z,F,U,Ke,_n,G,Ue,ut,fe,Rt,He,bn,Q,ct=!1,Tn=!1,Ln=[],Ge,ye,Er,Sr,Yo,Jo,qt,at,zt,Ht=!1,vn=!1,En,te,Ar=[],Mr=!1,In=[],Mn=typeof document<"u",yn=ns,Qo=Ut||$e?"cssFloat":"float",ch=Mn&&!is&&!ns&&"draggable"in document.createElement("div"),ls=function(){if(Mn){if($e)return!1;var n=document.createElement("x");return n.style.cssText="pointer-events:auto",n.style.pointerEvents==="auto"}}(),cs=function(e,t){var i=A(e),r=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=ht(e,0,t),s=ht(e,1,t),a=o&&A(o),l=s&&A(s),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+j(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+j(s).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=r&&i[Qo]==="none"||s&&i[Qo]==="none"&&c+u>r)?"vertical":"horizontal"},uh=function(e,t,i){var r=i?e.left:e.top,o=i?e.right:e.bottom,s=i?e.width:e.height,a=i?t.left:t.top,l=i?t.right:t.bottom,c=i?t.width:t.height;return r===a||o===l||r+s/2===a+c/2},hh=function(e,t){var i;return Ln.some(function(r){var o=r[ne].options.emptyInsertThreshold;if(!(!o||Pr(r))){var s=j(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return i=r}}),i},us=function(e){function t(o,s){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,c,u),s)(a,l,c,u);var d=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===d||o.join&&o.indexOf(d)>-1}}var i={},r=e.group;(!r||Cn(r)!="object")&&(r={name:r}),i.name=r.name,i.checkPull=t(r.pull,!0),i.checkPut=t(r.put),i.revertClone=r.revertClone,e.group=i},hs=function(){!ls&&F&&A(F,"display","none")},ds=function(){!ls&&F&&A(F,"display","")};Mn&&!is&&document.addEventListener("click",function(n){if(Tn)return n.preventDefault(),n.stopPropagation&&n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation(),Tn=!1,!1},!0);var Ze=function(e){if(C){e=e.touches?e.touches[0]:e;var t=hh(e.clientX,e.clientY);if(t){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]=e[r]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[ne]._onDragOver(i)}}},dh=function(e){C&&C.parentNode[ne]._isOutsideThisEl(e.target)};function $(n,e){if(!(n&&n.nodeType&&n.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(n));this.el=n,this.options=e=ke({},e),n[ne]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(n.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return cs(n,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(s,a){s.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:$.supportPointer!==!1&&"PointerEvent"in window&&!Ot,emptyInsertThreshold:5};jt.initializePlugins(this,n,t);for(var i in t)!(i in e)&&(e[i]=t[i]);us(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:ch,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?P(n,"pointerdown",this._onTapStart):(P(n,"mousedown",this._onTapStart),P(n,"touchstart",this._onTapStart)),this.nativeDraggable&&(P(n,"dragover",this),P(n,"dragenter",this)),Ln.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ke(this,oh())}$.prototype={constructor:$,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(at=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,C):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if(wh(i),!C&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Ot&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=xe(l,r.draggable,i,!1),!(l&&l.animated)&&_n!==l)){if(ut=Y(l),Rt=Y(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){oe({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:i,fromEl:i}),ae("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=xe(c,h.trim(),i,!1),h)return oe({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:i,toEl:i}),ae("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!xe(c,r.handle,i,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,i){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(i&&!C&&i.parentNode===o){var c=j(i);if(U=o,C=i,Z=C.parentNode,Ke=C.nextSibling,_n=i,bn=s.group,$.dragged=C,Ge={target:C,clientX:(t||e).clientX,clientY:(t||e).clientY},Yo=Ge.clientX-c.left,Jo=Ge.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,C.style["will-change"]="all",l=function(){if(ae("delayEnded",r,{evt:e}),$.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Wo&&r.nativeDraggable&&(C.draggable=!0),r._triggerDragStart(e,t),oe({sortable:r,name:"choose",originalEvent:e}),X(C,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){os(C,u.trim(),Dr)}),P(a,"dragover",Ze),P(a,"mousemove",Ze),P(a,"touchmove",Ze),P(a,"mouseup",r._onDrop),P(a,"touchend",r._onDrop),P(a,"touchcancel",r._onDrop),Wo&&this.nativeDraggable&&(this.options.touchStartThreshold=4,C.draggable=!0),ae("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Ut||$e))){if($.eventCanceled){this._onDrop();return}P(a,"mouseup",r._disableDelayedDrag),P(a,"touchend",r._disableDelayedDrag),P(a,"touchcancel",r._disableDelayedDrag),P(a,"mousemove",r._delayedDragTouchMoveHandler),P(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&P(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){C&&Dr(C),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._disableDelayedDrag),B(e,"touchend",this._disableDelayedDrag),B(e,"touchcancel",this._disableDelayedDrag),B(e,"mousemove",this._delayedDragTouchMoveHandler),B(e,"touchmove",this._delayedDragTouchMoveHandler),B(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?P(document,"pointermove",this._onTouchMove):t?P(document,"touchmove",this._onTouchMove):P(document,"mousemove",this._onTouchMove):(P(C,"dragend",this),P(U,"dragstart",this._onDragStart));try{document.selection?Sn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ct=!1,U&&C){ae("dragStarted",this,{evt:t}),this.nativeDraggable&&P(document,"dragover",dh);var i=this.options;!e&&X(C,i.dragClass,!1),X(C,i.ghostClass,!0),$.active=this,e&&this._appendGhost(),oe({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(ye){this._lastX=ye.clientX,this._lastY=ye.clientY,hs();for(var e=document.elementFromPoint(ye.clientX,ye.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(ye.clientX,ye.clientY),e!==t);)t=e;if(C.parentNode[ne]._isOutsideThisEl(e),t)do{if(t[ne]){var i=void 0;if(i=t[ne]._onDragOver({clientX:ye.clientX,clientY:ye.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);ds()}},_onTouchMove:function(e){if(Ge){var t=this.options,i=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=F&&Xe(F,!0),a=F&&s&&s.a,l=F&&s&&s.d,c=yn&&te&&Ko(te),u=(o.clientX-Ge.clientX+r.x)/(a||1)+(c?c[0]-Ar[0]:0)/(a||1),h=(o.clientY-Ge.clientY+r.y)/(l||1)+(c?c[1]-Ar[1]:0)/(l||1);if(!$.active&&!ct){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(F){s?(s.e+=u-(Er||0),s.f+=h-(Sr||0)):s={a:1,b:0,c:0,d:1,e:u,f:h};var d="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");A(F,"webkitTransform",d),A(F,"mozTransform",d),A(F,"msTransform",d),A(F,"transform",d),Er=u,Sr=h,ye=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!F){var e=this.options.fallbackOnBody?document.body:U,t=j(C,!0,yn,!0,e),i=this.options;if(yn){for(te=e;A(te,"position")==="static"&&A(te,"transform")==="none"&&te!==document;)te=te.parentNode;te!==document.body&&te!==document.documentElement?(te===document&&(te=Ee()),t.top+=te.scrollTop,t.left+=te.scrollLeft):te=Ee(),Ar=Ko(te)}F=C.cloneNode(!0),X(F,i.ghostClass,!1),X(F,i.fallbackClass,!0),X(F,i.dragClass,!0),A(F,"transition",""),A(F,"transform",""),A(F,"box-sizing","border-box"),A(F,"margin",0),A(F,"top",t.top),A(F,"left",t.left),A(F,"width",t.width),A(F,"height",t.height),A(F,"opacity","0.8"),A(F,"position",yn?"absolute":"fixed"),A(F,"zIndex","100000"),A(F,"pointerEvents","none"),$.ghost=F,e.appendChild(F),A(F,"transform-origin",Yo/parseInt(F.style.width)*100+"% "+Jo/parseInt(F.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,r=e.dataTransfer,o=i.options;if(ae("dragStart",this,{evt:e}),$.eventCanceled){this._onDrop();return}ae("setupClone",this),$.eventCanceled||(G=Or(C),G.removeAttribute("id"),G.draggable=!1,G.style["will-change"]="",this._hideClone(),X(G,this.options.chosenClass,!1),$.clone=G),i.cloneId=Sn(function(){ae("clone",i),!$.eventCanceled&&(i.options.removeCloneOnHide||U.insertBefore(G,C),i._hideClone(),oe({sortable:i,name:"clone"}))}),!t&&X(C,o.dragClass,!0),t?(Tn=!0,i._loopId=setInterval(i._emulateDragOver,50)):(B(document,"mouseup",i._onDrop),B(document,"touchend",i._onDrop),B(document,"touchcancel",i._onDrop),r&&(r.effectAllowed="move",o.setData&&o.setData.call(i,r,C)),P(document,"drop",i),A(C,"transform","translateZ(0)")),ct=!0,i._dragStartId=Sn(i._dragStarted.bind(i,t,e)),P(document,"selectstart",i),qt=!0,Ot&&A(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,r,o,s,a=this.options,l=a.group,c=$.active,u=bn===l,h=a.sort,d=Q||c,p,f=this,m=!1;if(Mr)return;function w(Oe,gu){ae(Oe,f,Se({evt:e,isOwner:u,axis:p?"vertical":"horizontal",revert:s,dragRect:r,targetRect:o,canSort:h,fromSortable:d,target:i,completed:g,onMove:function(Fo,bu){return wn(U,t,C,r,Fo,j(Fo),e,bu)},changed:k},gu))}function v(){w("dragOverAnimationCapture"),f.captureAnimationState(),f!==d&&d.captureAnimationState()}function g(Oe){return w("dragOverCompleted",{insertion:Oe}),Oe&&(u?c._hideClone():c._showClone(f),f!==d&&(X(C,Q?Q.options.ghostClass:c.options.ghostClass,!1),X(C,a.ghostClass,!0)),Q!==f&&f!==$.active?Q=f:f===$.active&&Q&&(Q=null),d===f&&(f._ignoreWhileAnimating=i),f.animateAll(function(){w("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(i===C&&!C.animated||i===t&&!i.animated)&&(at=null),!a.dragoverBubble&&!e.rootEl&&i!==document&&(C.parentNode[ne]._isOutsideThisEl(e.target),!Oe&&Ze(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function k(){fe=Y(C),He=Y(C,a.draggable),oe({sortable:f,name:"change",toEl:t,newIndex:fe,newDraggableIndex:He,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=xe(i,a.draggable,t,!0),w("dragOver"),$.eventCanceled)return m;if(C.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||f._ignoreWhileAnimating===i)return g(!1);if(Tn=!1,c&&!a.disabled&&(u?h||(s=Z!==U):Q===this||(this.lastPutMode=bn.checkPull(this,c,C,e))&&l.checkPut(this,c,C,e))){if(p=this._getDirection(e,i)==="vertical",r=j(C),w("dragOverValid"),$.eventCanceled)return m;if(s)return Z=U,v(),this._hideClone(),w("revert"),$.eventCanceled||(Ke?U.insertBefore(C,Ke):U.appendChild(C)),g(!0);var y=Pr(t,a.draggable);if(!y||gh(e,p,this)&&!y.animated){if(y===C)return g(!1);if(y&&t===e.target&&(i=y),i&&(o=j(i)),wn(U,t,C,r,i,o,e,!!i)!==!1)return v(),y&&y.nextSibling?t.insertBefore(C,y.nextSibling):t.appendChild(C),Z=t,k(),g(!0)}else if(y&&mh(e,p,this)){var _=ht(t,0,a,!0);if(_===C)return g(!1);if(i=_,o=j(i),wn(U,t,C,r,i,o,e,!1)!==!1)return v(),t.insertBefore(C,_),Z=t,k(),g(!0)}else if(i.parentNode===t){o=j(i);var x=0,S,D=C.parentNode!==t,q=!uh(C.animated&&C.toRect||r,i.animated&&i.toRect||o,p),L=p?"top":"left",I=Zo(i,"top","top")||Zo(C,"top","top"),H=I?I.scrollTop:void 0;at!==i&&(S=o[L],Ht=!1,vn=!q&&a.invertSwap||D),x=bh(e,i,o,p,q?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vn,at===i);var R;if(x!==0){var ee=Y(C);do ee-=x,R=Z.children[ee];while(R&&(A(R,"display")==="none"||R===F))}if(x===0||R===i)return g(!1);at=i,zt=x;var ge=i.nextElementSibling,V=!1;V=x===1;var Pe=wn(U,t,C,r,i,o,e,V);if(Pe!==!1)return(Pe===1||Pe===-1)&&(V=Pe===1),Mr=!0,setTimeout(fh,30),v(),V&&!ge?t.appendChild(C):i.parentNode.insertBefore(C,V?ge:i),I&&as(I,0,H-I.scrollTop),Z=C.parentNode,S!==void 0&&!vn&&(En=Math.abs(S-j(i)[L])),k(),g(!0)}if(t.contains(C))return g(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){B(document,"mousemove",this._onTouchMove),B(document,"touchmove",this._onTouchMove),B(document,"pointermove",this._onTouchMove),B(document,"dragover",Ze),B(document,"mousemove",Ze),B(document,"touchmove",Ze)},_offUpEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._onDrop),B(e,"touchend",this._onDrop),B(e,"pointerup",this._onDrop),B(e,"touchcancel",this._onDrop),B(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(fe=Y(C),He=Y(C,i.draggable),ae("drop",this,{evt:e}),Z=C&&C.parentNode,fe=Y(C),He=Y(C,i.draggable),$.eventCanceled){this._nulling();return}ct=!1,vn=!1,Ht=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Fr(this.cloneId),Fr(this._dragStartId),this.nativeDraggable&&(B(document,"drop",this),B(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Ot&&A(document.body,"user-select",""),A(C,"transform",""),e&&(qt&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),F&&F.parentNode&&F.parentNode.removeChild(F),(U===Z||Q&&Q.lastPutMode!=="clone")&&G&&G.parentNode&&G.parentNode.removeChild(G),C&&(this.nativeDraggable&&B(C,"dragend",this),Dr(C),C.style["will-change"]="",qt&&!ct&&X(C,Q?Q.options.ghostClass:this.options.ghostClass,!1),X(C,this.options.chosenClass,!1),oe({sortable:this,name:"unchoose",toEl:Z,newIndex:null,newDraggableIndex:null,originalEvent:e}),U!==Z?(fe>=0&&(oe({rootEl:Z,name:"add",toEl:Z,fromEl:U,originalEvent:e}),oe({sortable:this,name:"remove",toEl:Z,originalEvent:e}),oe({rootEl:Z,name:"sort",toEl:Z,fromEl:U,originalEvent:e}),oe({sortable:this,name:"sort",toEl:Z,originalEvent:e})),Q&&Q.save()):fe!==ut&&fe>=0&&(oe({sortable:this,name:"update",toEl:Z,originalEvent:e}),oe({sortable:this,name:"sort",toEl:Z,originalEvent:e})),$.active&&((fe==null||fe===-1)&&(fe=ut,He=Rt),oe({sortable:this,name:"end",toEl:Z,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ae("nulling",this),U=C=Z=F=Ke=G=_n=Ue=Ge=ye=qt=fe=He=ut=Rt=at=zt=Q=bn=$.dragged=$.ghost=$.clone=$.active=null,In.forEach(function(e){e.checked=!0}),In.length=Er=Sr=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":C&&(this._onDragOver(e),ph(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,r=0,o=i.length,s=this.options;r<o;r++)t=i[r],xe(t,s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||yh(t));return e},sort:function(e,t){var i={},r=this.el;this.toArray().forEach(function(o,s){var a=r.children[s];xe(a,this.options.draggable,r,!1)&&(i[o]=a)},this),t&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(r.removeChild(i[o]),r.appendChild(i[o]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return xe(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var r=jt.modifyOption(this,e,t);typeof r<"u"?i[e]=r:i[e]=t,e==="group"&&us(i)},destroy:function(){ae("destroy",this);var e=this.el;e[ne]=null,B(e,"mousedown",this._onTapStart),B(e,"touchstart",this._onTapStart),B(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(B(e,"dragover",this),B(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ln.splice(Ln.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ue){if(ae("hideClone",this),$.eventCanceled)return;A(G,"display","none"),this.options.removeCloneOnHide&&G.parentNode&&G.parentNode.removeChild(G),Ue=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ue){if(ae("showClone",this),$.eventCanceled)return;C.parentNode==U&&!this.options.group.revertClone?U.insertBefore(G,C):Ke?U.insertBefore(G,Ke):U.appendChild(G),this.options.group.revertClone&&this.animate(C,G),A(G,"display",""),Ue=!1}}};function ph(n){n.dataTransfer&&(n.dataTransfer.dropEffect="move"),n.cancelable&&n.preventDefault()}function wn(n,e,t,i,r,o,s,a){var l,c=n[ne],u=c.options.onMove,h;return window.CustomEvent&&!$e&&!Ut?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=n,l.dragged=t,l.draggedRect=i,l.related=r||e,l.relatedRect=o||j(e),l.willInsertAfter=a,l.originalEvent=s,n.dispatchEvent(l),u&&(h=u.call(c,l,s)),h}function Dr(n){n.draggable=!1}function fh(){Mr=!1}function mh(n,e,t){var i=j(ht(t.el,0,t.options,!0)),r=10;return e?n.clientX<i.left-r||n.clientY<i.top&&n.clientX<i.right:n.clientY<i.top-r||n.clientY<i.bottom&&n.clientX<i.left}function gh(n,e,t){var i=j(Pr(t.el,t.options.draggable)),r=10;return e?n.clientX>i.right+r||n.clientX<=i.right&&n.clientY>i.bottom&&n.clientX>=i.left:n.clientX>i.right&&n.clientY>i.top||n.clientX<=i.right&&n.clientY>i.bottom+r}function bh(n,e,t,i,r,o,s,a){var l=i?n.clientY:n.clientX,c=i?t.height:t.width,u=i?t.top:t.left,h=i?t.bottom:t.right,d=!1;if(!s){if(a&&En<c*r){if(!Ht&&(zt===1?l>u+c*o/2:l<h-c*o/2)&&(Ht=!0),Ht)d=!0;else if(zt===1?l<u+En:l>h-En)return-zt}else if(l>u+c*(1-r)/2&&l<h-c*(1-r)/2)return vh(e)}return d=d||s,d&&(l<u+c*o/2||l>h-c*o/2)?l>u+c/2?1:-1:0}function vh(n){return Y(C)<Y(n)?1:-1}function yh(n){for(var e=n.tagName+n.className+n.src+n.href+n.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function wh(n){In.length=0;for(var e=n.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&In.push(i)}}function Sn(n){return setTimeout(n,0)}function Fr(n){return clearTimeout(n)}Mn&&P(document,"touchmove",function(n){($.active||ct)&&n.cancelable&&n.preventDefault()});$.utils={on:P,off:B,css:A,find:os,is:function(e,t){return!!xe(e,t,e,!1)},extend:ih,throttle:ss,closest:xe,toggleClass:X,clone:Or,index:Y,nextTick:Sn,cancelNextTick:Fr,detectDirection:cs,getChild:ht};$.get=function(n){return n[ne]};$.mount=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&($.utils=Se(Se({},$.utils),i.utils)),jt.mount(i)})};$.create=function(n,e){return new $(n,e)};$.version=eh;var K=[],Bt,qr,Br=!1,Tr,Lr,$n,Pt;function xh(){function n(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return n.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?P(document,"dragover",this._handleAutoScroll):this.options.supportPointer?P(document,"pointermove",this._handleFallbackAutoScroll):i.touches?P(document,"touchmove",this._handleFallbackAutoScroll):P(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?B(document,"dragover",this._handleAutoScroll):(B(document,"pointermove",this._handleFallbackAutoScroll),B(document,"touchmove",this._handleFallbackAutoScroll),B(document,"mousemove",this._handleFallbackAutoScroll)),es(),An(),rh()},nulling:function(){$n=qr=Bt=Br=Pt=Tr=Lr=null,K.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var r=this,o=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(o,s);if($n=t,i||this.options.forceAutoScrollFallback||Ut||$e||Ot){Ir(t,this.options,a,i);var l=je(a,!0);Br&&(!Pt||o!==Tr||s!==Lr)&&(Pt&&es(),Pt=setInterval(function(){var c=je(document.elementFromPoint(o,s),!0);c!==l&&(l=c,An()),Ir(t,r.options,c,i)},10),Tr=o,Lr=s)}else{if(!this.options.bubbleScroll||je(a,!0)===Ee()){An();return}Ir(t,this.options,je(a,!1),!1)}}},ke(n,{pluginName:"scroll",initializeByDefault:!0})}function An(){K.forEach(function(n){clearInterval(n.pid)}),K=[]}function es(){clearInterval(Pt)}var Ir=ss(function(n,e,t,i){if(e.scroll){var r=(n.touches?n.touches[0]:n).clientX,o=(n.touches?n.touches[0]:n).clientY,s=e.scrollSensitivity,a=e.scrollSpeed,l=Ee(),c=!1,u;qr!==t&&(qr=t,An(),Bt=e.scroll,u=e.scrollFn,Bt===!0&&(Bt=je(t,!0)));var h=0,d=Bt;do{var p=d,f=j(p),m=f.top,w=f.bottom,v=f.left,g=f.right,k=f.width,y=f.height,_=void 0,x=void 0,S=p.scrollWidth,D=p.scrollHeight,q=A(p),L=p.scrollLeft,I=p.scrollTop;p===l?(_=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"||q.overflowX==="visible"),x=y<D&&(q.overflowY==="auto"||q.overflowY==="scroll"||q.overflowY==="visible")):(_=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"),x=y<D&&(q.overflowY==="auto"||q.overflowY==="scroll"));var H=_&&(Math.abs(g-r)<=s&&L+k<S)-(Math.abs(v-r)<=s&&!!L),R=x&&(Math.abs(w-o)<=s&&I+y<D)-(Math.abs(m-o)<=s&&!!I);if(!K[h])for(var ee=0;ee<=h;ee++)K[ee]||(K[ee]={});(K[h].vx!=H||K[h].vy!=R||K[h].el!==p)&&(K[h].el=p,K[h].vx=H,K[h].vy=R,clearInterval(K[h].pid),(H!=0||R!=0)&&(c=!0,K[h].pid=setInterval(function(){i&&this.layer===0&&$.active._onTouchMove($n);var ge=K[this.layer].vy?K[this.layer].vy*a:0,V=K[this.layer].vx?K[this.layer].vx*a:0;typeof u=="function"&&u.call($.dragged.parentNode[ne],V,ge,n,$n,K[this.layer].el)!=="continue"||as(K[this.layer].el,V,ge)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&d!==l&&(d=je(d,!1)));Br=c}},30),ps=function(e){var t=e.originalEvent,i=e.putSortable,r=e.dragEl,o=e.activeSortable,s=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=i||o;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(s("spill"),this.onSpill({dragEl:r,putSortable:i}))}};function Nr(){}Nr.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var r=ht(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:ps};ke(Nr,{pluginName:"revertOnSpill"});function Rr(){}Rr.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,r=i||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:ps};ke(Rr,{pluginName:"removeOnSpill"});var M=[],pe=[],It,we,$t=!1,le=!1,lt=!1,z,Mt,xn;function fs(){function n(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?P(document,"pointerup",this._deselectMultiDrag):(P(document,"mouseup",this._deselectMultiDrag),P(document,"touchend",this._deselectMultiDrag))),P(document,"keydown",this._checkKeyDown),P(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(r,o){var s="";M.length&&we===e?M.forEach(function(a,l){s+=(l?", ":"")+a.textContent}):s=o.textContent,r.setData("Text",s)}}}return n.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var i=t.dragEl;z=i},delayEnded:function(){this.isMultiDrag=~M.indexOf(z)},setupClone:function(t){var i=t.sortable,r=t.cancel;if(this.isMultiDrag){for(var o=0;o<M.length;o++)pe.push(Or(M[o])),pe[o].sortableIndex=M[o].sortableIndex,pe[o].draggable=!1,pe[o].style["will-change"]="",X(pe[o],this.options.selectedClass,!1),M[o]===z&&X(pe[o],this.options.chosenClass,!1);i._hideClone(),r()}},clone:function(t){var i=t.sortable,r=t.rootEl,o=t.dispatchSortableEvent,s=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||M.length&&we===i&&(ts(!0,r),o("clone"),s()))},showClone:function(t){var i=t.cloneNowShown,r=t.rootEl,o=t.cancel;this.isMultiDrag&&(ts(!1,r),pe.forEach(function(s){A(s,"display","")}),i(),xn=!1,o())},hideClone:function(t){var i=this,r=t.sortable,o=t.cloneNowHidden,s=t.cancel;this.isMultiDrag&&(pe.forEach(function(a){A(a,"display","none"),i.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),o(),xn=!0,s())},dragStartGlobal:function(t){var i=t.sortable;!this.isMultiDrag&&we&&we.multiDrag._deselectMultiDrag(),M.forEach(function(r){r.sortableIndex=Y(r)}),M=M.sort(function(r,o){return r.sortableIndex-o.sortableIndex}),lt=!0},dragStarted:function(t){var i=this,r=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(r.captureAnimationState(),this.options.animation)){M.forEach(function(s){s!==z&&A(s,"position","absolute")});var o=j(z,!1,!0,!0);M.forEach(function(s){s!==z&&Xo(s,o)}),le=!0,$t=!0}r.animateAll(function(){le=!1,$t=!1,i.options.animation&&M.forEach(function(s){Cr(s)}),i.options.sort&&kn()})}},dragOver:function(t){var i=t.target,r=t.completed,o=t.cancel;le&&~M.indexOf(i)&&(r(!1),o())},revert:function(t){var i=t.fromSortable,r=t.rootEl,o=t.sortable,s=t.dragRect;M.length>1&&(M.forEach(function(a){o.addAnimationState({target:a,rect:le?j(a):s}),Cr(a),a.fromRect=s,i.removeAnimationState(a)}),le=!1,kh(!this.options.removeCloneOnHide,r))},dragOverCompleted:function(t){var i=t.sortable,r=t.isOwner,o=t.insertion,s=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(o){if(r&&s._hideClone(),$t=!1,c.animation&&M.length>1&&(le||!r&&!s.options.sort&&!l)){var u=j(z,!1,!0,!0);M.forEach(function(d){d!==z&&(Xo(d,u),a.appendChild(d))}),le=!0}if(!r)if(le||kn(),M.length>1){var h=xn;s._showClone(i),s.options.animation&&!xn&&h&&pe.forEach(function(d){s.addAnimationState({target:d,rect:Mt}),d.fromRect=Mt,d.thisAnimationDuration=null})}else s._showClone(i)}},dragOverAnimationCapture:function(t){var i=t.dragRect,r=t.isOwner,o=t.activeSortable;if(M.forEach(function(a){a.thisAnimationDuration=null}),o.options.animation&&!r&&o.multiDrag.isMultiDrag){Mt=ke({},i);var s=Xe(z,!0);Mt.top-=s.f,Mt.left-=s.e}},dragOverAnimationComplete:function(){le&&(le=!1,kn())},drop:function(t){var i=t.originalEvent,r=t.rootEl,o=t.parentEl,s=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(i){var h=this.options,d=o.children;if(!lt)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),X(z,h.selectedClass,!~M.indexOf(z)),~M.indexOf(z))M.splice(M.indexOf(z),1),It=null,Ft({sortable:s,rootEl:r,name:"deselect",targetEl:z,originalEvent:i});else{if(M.push(z),Ft({sortable:s,rootEl:r,name:"select",targetEl:z,originalEvent:i}),i.shiftKey&&It&&s.el.contains(It)){var p=Y(It),f=Y(z);if(~p&&~f&&p!==f){var m,w;for(f>p?(w=p,m=f):(w=f,m=p+1);w<m;w++)~M.indexOf(d[w])||(X(d[w],h.selectedClass,!0),M.push(d[w]),Ft({sortable:s,rootEl:r,name:"select",targetEl:d[w],originalEvent:i}))}}else It=z;we=u}if(lt&&this.isMultiDrag){if(le=!1,(o[ne].options.sort||o!==r)&&M.length>1){var v=j(z),g=Y(z,":not(."+this.options.selectedClass+")");if(!$t&&h.animation&&(z.thisAnimationDuration=null),u.captureAnimationState(),!$t&&(h.animation&&(z.fromRect=v,M.forEach(function(y){if(y.thisAnimationDuration=null,y!==z){var _=le?j(y):v;y.fromRect=_,u.addAnimationState({target:y,rect:_})}})),kn(),M.forEach(function(y){d[g]?o.insertBefore(y,d[g]):o.appendChild(y),g++}),l===Y(z))){var k=!1;M.forEach(function(y){if(y.sortableIndex!==Y(y)){k=!0;return}}),k&&a("update")}M.forEach(function(y){Cr(y)}),u.animateAll()}we=u}(r===o||c&&c.lastPutMode!=="clone")&&pe.forEach(function(y){y.parentNode&&y.parentNode.removeChild(y)})}},nullingGlobal:function(){this.isMultiDrag=lt=!1,pe.length=0},destroyGlobal:function(){this._deselectMultiDrag(),B(document,"pointerup",this._deselectMultiDrag),B(document,"mouseup",this._deselectMultiDrag),B(document,"touchend",this._deselectMultiDrag),B(document,"keydown",this._checkKeyDown),B(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof lt<"u"&<)&&we===this.sortable&&!(t&&xe(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;M.length;){var i=M[0];X(i,this.options.selectedClass,!1),M.shift(),Ft({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:i,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},ke(n,{pluginName:"multiDrag",utils:{select:function(t){var i=t.parentNode[ne];!i||!i.options.multiDrag||~M.indexOf(t)||(we&&we!==i&&(we.multiDrag._deselectMultiDrag(),we=i),X(t,i.options.selectedClass,!0),M.push(t))},deselect:function(t){var i=t.parentNode[ne],r=M.indexOf(t);!i||!i.options.multiDrag||!~r||(X(t,i.options.selectedClass,!1),M.splice(r,1))}},eventProperties:function(){var t=this,i=[],r=[];return M.forEach(function(o){i.push({multiDragElement:o,index:o.sortableIndex});var s;le&&o!==z?s=-1:le?s=Y(o,":not(."+t.options.selectedClass+")"):s=Y(o),r.push({multiDragElement:o,index:s})}),{items:Ku(M),clones:[].concat(pe),oldIndicies:i,newIndicies:r}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function kh(n,e){M.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function ts(n,e){pe.forEach(function(t,i){var r=e.children[t.sortableIndex+(n?Number(i):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function kn(){M.forEach(function(n){n!==z&&n.parentNode&&n.parentNode.removeChild(n)})}$.mount(new xh);$.mount(Rr,Nr);var Ye=$;var ms={name(n,e){let t=n.getAttribute("data-name").trim().toLowerCase(),i=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(i)},created(n,e){let t=Number(n.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(n,e){let t=Number(n.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?-1:1},chaptersLast(n,e){let t=n.getAttribute("data-type"),i=e.getAttribute("data-type");return t===i?0:t==="chapter"?1:-1}},gs={up:{active(n,e){return!(n.previousElementSibling===null&&!e)},run(n,e){(n.previousElementSibling||e).insertAdjacentElement("beforebegin",n)}},down:{active(n,e){return!(n.nextElementSibling===null&&!e)},run(n,e){(n.nextElementSibling||e).insertAdjacentElement("afterend",n)}},next_book:{active(n,e,t){return t.nextElementSibling!==null},run(n,e,t){t.nextElementSibling.querySelector("ul").prepend(n)}},prev_book:{active(n,e,t){return t.previousElementSibling!==null},run(n,e,t){t.previousElementSibling.querySelector("ul").appendChild(n)}},next_chapter:{active(n,e){return n.dataset.type==="page"&&this.getNextChapter(n,e)},run(n,e){this.getNextChapter(n,e).querySelector("ul").prepend(n)},getNextChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(r+1).find(o=>o.dataset.type==="chapter")}},prev_chapter:{active(n,e){return n.dataset.type==="page"&&this.getPrevChapter(n,e)},run(n,e){this.getPrevChapter(n,e).querySelector("ul").append(n)},getPrevChapter(n,e){let t=e||n,i=Array.from(t.parentElement.children),r=i.indexOf(t);return i.slice(0,r).reverse().find(o=>o.dataset.type==="chapter")}},book_end:{active(n,e){return e||e===null&&n.nextElementSibling},run(n,e,t){t.querySelector("ul").append(n)}},book_start:{active(n,e){return e||e===null&&n.previousElementSibling},run(n,e,t){t.querySelector("ul").prepend(n)}},before_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("beforebegin",n)}},after_chapter:{active(n,e){return e},run(n,e){e.insertAdjacentElement("afterend",n)}}},Fn=class extends b{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,Ye.mount(new fs);let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",e=>{if(e.target.matches("[data-move]")){let t=e.target.getAttribute("data-move"),i=e.target.closest("[data-id]");this.runSortAction(i,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,i=["name","created","updated"];this.sortContainer.addEventListener("click",r=>{let o=r.target.closest(".sort-box-options [data-sort]");if(!o)return;r.preventDefault();let s=o.closest(".sort-box").querySelectorAll("ul"),a=o.getAttribute("data-sort");t=e===a?!t:!1;let l=ms[a];t&&i.includes(a)&&(l=function(u,h){return 0-ms[a](u,h)});for(let c of s)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let i=`${e.link}/sort-item`;window.$http.get(i).then(r=>{let o=Ne(r.data);this.sortContainer.append(o),this.setupBookSortable(o),this.updateMoveActionStateForAll(),o.querySelector("summary").focus()})}setupBookSortable(e){let t=Array.from(e.querySelectorAll(".sort-list, .sortable-page-sublist")),i={name:"book",pull:["book","chapter"],put:["book","chapter"]},r={name:"chapter",pull:["book","chapter"],put(o,s,a){return a.getAttribute("data-type")==="page"}};for(let o of t)Ye.create(o,{group:o.classList.contains("sort-list")?i:r,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let e=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let t of e)t.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",t)}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.container.querySelectorAll(".sort-list");for(let i of t){let r=i.closest('[data-type="book"]').getAttribute("data-id"),o=Array.from(i.children).filter(s=>s.matches('[data-type="page"], [data-type="chapter"]'));for(let s=0;s<o.length;s++)this.addBookChildToMap(o[s],s,r,e)}return e}addBookChildToMap(e,t,i,r){let o=e.getAttribute("data-type"),s=!1,a=e.getAttribute("data-id");r.push({id:a,sort:t,parentChapter:s,type:o,book:i});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)r.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:i})}runSortAction(e,t){let i=e.parentElement.closest("li[data-id]"),r=e.parentElement.closest('[data-type="book"]');gs[t].run(e,i,r),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),i=e.parentElement.closest('[data-type="book"]');for(let[r,o]of Object.entries(gs)){let s=e.querySelector(`[data-move="${r}"]`);s.disabled=!o.active(e,t,i)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var qn=new WeakMap;function Vt(n,e,t=400,i=null){let r=Object.keys(e);for(let s of r)n.style[s]=e[s][0];let o=()=>{for(let s of r)n.style[s]=null;n.style.transition=null,n.removeEventListener("transitionend",o),qn.delete(n),i&&i()};setTimeout(()=>{n.style.transition=`all ease-in-out ${t}ms`;for(let s of r)n.style[s]=e[s][1];n.addEventListener("transitionend",o),qn.set(n,o)},15)}function Wt(n){qn.has(n)&&qn.get(n)()}function bs(n,e=400,t=null){Wt(n),n.style.display="block",Vt(n,{opacity:["0","1"]},e,()=>{t&&t()})}function vs(n,e=400,t=null){Wt(n),Vt(n,{opacity:["1","0"]},e,()=>{n.style.display="none",t&&t()})}function dt(n,e=400){Wt(n);let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[r,"0px"],paddingBottom:[o,"0px"]};Vt(n,s,e,()=>{n.style.display="none"})}function pt(n,e=400){Wt(n),n.style.display="block";let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom"),s={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",r],paddingBottom:["0px",o]};Vt(n,s,e)}function ys(n,e=400){let t=n.getBoundingClientRect().height,i=getComputedStyle(n),r=i.getPropertyValue("padding-top"),o=i.getPropertyValue("padding-bottom");return()=>{Wt(n);let s=n.getBoundingClientRect().height,a=getComputedStyle(n),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${s}px`],overflow:["hidden","hidden"],paddingTop:[r,l],paddingBottom:[o,c]};Vt(n,u,e)}}var Bn=class extends b{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),pt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),dt(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Pn=class extends b{constructor(){super(...arguments);se(this,"editor",null);se(this,"saveCallback",null);se(this,"cancelCallback",null);se(this,"history",{});se(this,"historyKey","code_history")}setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",t=>{t.ctrlKey&&t.key==="Enter"&&this.save()}),N(this.languageButtons,t=>{let i=t.target.dataset.lang;this.languageInput.value=i,this.languageInputChange(i)}),ln(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),N(this.saveButton,()=>this.save()),W(this.historyList,"button","click",(t,i)=>{t.preventDefault();let r=i.dataset.time;this.editor&&this.editor.setContent(this.history[r])})}setupFavourites(){for(let t of this.languageButtons)this.setupFavouritesForButton(t);this.sortLanguageList()}setupFavouritesForButton(t){let i=t.dataset.lang,r=this.favourites.has(i);t.setAttribute("data-favourite",r?"true":"false"),W(t.parentElement,".lang-option-favorite-toggle","click",()=>{r=!r,r?this.favourites.add(i):this.favourites.delete(i),t.setAttribute("data-favourite",r?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:i,active:r}),this.sortLanguageList(),r&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((i,r)=>{let o=i.dataset.favourite==="true",s=r.dataset.favourite==="true";return o&&!s?-1:s&&!o||i.dataset.lang>r.dataset.lang?1:-1}).map(i=>i.parentElement);for(let i of t)this.languageOptionsContainer.append(i)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,i,r,o){this.languageInput.value=i,this.saveCallback=r,this.cancelCallback=o,await this.show(),this.languageInputChange(i),this.editor.setContent(t)}async show(){let t=await window.importVersioned("code");this.editor||(this.editor=t.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(t){this.editor.setMode(t,this.editor.getContent())}languageInputChange(t){this.updateEditorMode(t);let i=t.toLowerCase();for(let r of this.languageButtons){let o=r.dataset.lang.toLowerCase().trim(),s=i===o;r.classList.toggle("active",s),s&&r.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let t=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",t.length===0),this.historyList.innerHTML=t.map(i=>{let r=new Date(parseInt(i,10)).toLocaleTimeString();return`<li><button type="button" data-time="${i}" class="text-item">${r}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let i=Object.keys(this.history).pop();if(this.history[i]===t)return;this.history[String(Date.now())]=t;let r=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,r)}};var On=class extends b{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(i=>{i.highlightWithin(e)})}};var Nn=class extends b{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Rn=class extends b{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),pt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),dt(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var zn=class extends b{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,N(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(e=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var Hn=class extends b{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var Un=class extends b{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var jn=class extends b{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),i=0,r=this.toggle.getBoundingClientRect().height,o=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,o?i=window.innerHeight-t.top-r/2:i=t.top),o?(this.menu.style.top="initial",this.menu.style.bottom=`${i}px`):(this.menu.style.top=`${i}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let s=this.menu.querySelector("input");s!==null&&s.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let e=new ze(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),N(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var Vn=class extends b{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Re(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let i of t){let r=!e||i.textContent.toLowerCase().includes(e);i.style.display=r?"flex":"none",i.classList.toggle("hidden",!r)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),i=ys(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,i()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var Me=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let{types:e}=this.data,t=[];for(let r of e)if(r.includes("image")){let o=this.data.getData(r);t.push(o.getAsFile())}let i=this.getFiles().filter(r=>r.type.includes("image"));return t.push(...i),t}getFiles(){let{files:e}=this.data;return[...e]}};async function ws(n){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(n);return}let e=document.createElement("textarea");e.style="position: absolute; left: -1000px; top: -1000px;",e.value=n,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Wn=class extends b{setup(){this.container=this.$el,this.statusArea=this.$refs.statusArea,this.dropTarget=this.$refs.dropTarget,this.selectButtons=this.$manyRefs.selectButton||[],this.isActive=!0,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.errorMessage=this.$opts.errorMessage,this.uploadLimitMb=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.zoneText=this.$opts.zoneText,this.fileAcceptTypes=this.$opts.fileAccept,this.allowMultiple=this.$opts.allowMultiple==="true",this.setupListeners()}toggleActive(e){this.isActive=e}setupListeners(){N(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let e=0,t=()=>{this.hideOverlay(),e=0};this.dropTarget.addEventListener("dragenter",i=>{i.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",i=>{i.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",i=>{if(i.preventDefault(),t(),!this.isActive)return;let o=new Me(i.dataTransfer).getFiles();for(let s of o)this.createUploadFromFile(s)})}manualSelectHandler(){let e=_e("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(e),e.click(),e.addEventListener("change",()=>{for(let t of e.files)this.createUploadFromFile(t);e.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let t=_e("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(t)}}hideOverlay(){let e=this.dropTarget.querySelector(".dropzone-overlay");e&&e.remove()}createUploadFromFile(e){let{dom:t,status:i,progress:r,dismiss:o}=this.createDomForFile(e);this.statusArea.append(t);let s=this,a={file:e,dom:t,updateProgress(l){r.textContent=`${l}%`,r.style.width=`${l}%`},markError(l){i.setAttribute("data-status","error"),i.textContent=l,At(t),this.updateProgress(100)},markSuccess(l){i.setAttribute("data-status","success"),i.textContent=l,At(t),setTimeout(o,2400),s.$emit("upload-success",{name:e.name})}};return e.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(e){let t=new FormData;t.append("file",e.file,e.file.name);let i=this,r=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(i.errorMessage)},readystatechange(){if(this.readyState===XMLHttpRequest.DONE&&this.status===200)e.markSuccess(i.successMessage);else if(this.readyState===XMLHttpRequest.DONE&&this.status>=400){let o=this.responseText,s=o.startsWith("{")?JSON.parse(o):{message:o},a=s?.message||s?.error||o;e.markError(a)}}});r.upload.addEventListener("progress",o=>{let s=Math.min(Math.ceil(o.loaded/o.total*100),100);e.updateProgress(s)}),r.setRequestHeader("Accept","application/json"),r.send(t)}createDomForFile(e){let t=_e("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),i=_e("div",{class:"dropzone-file-item-status"},[]),r=_e("div",{class:"dropzone-file-item-progress"}),o=_e("div",{class:"dropzone-file-item-image-wrap"},[t]),s=_e("div",{class:"dropzone-file-item"},[o,_e("div",{class:"dropzone-file-item-text-wrap"},[_e("div",{class:"dropzone-file-item-label"},[e.name]),Ho(),i]),r]);e.type.startsWith("image/")&&(t.src=URL.createObjectURL(e));let a=()=>{s.classList.add("dismiss"),s.addEventListener("animationend",()=>{s.remove()})};return s.addEventListener("click",a),{dom:s,progress:r,status:i,dismiss:a}}};var Gn=class extends b{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let i=t.dataset.tab;this.setActiveTab(i,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let i of this.buttons)i.classList.remove("active"),i.dataset.tab===e&&i.classList.add("active");for(let i of this.contentElements)i.style.display="none",i.dataset.tabContent===e&&(i.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Zn=class extends b{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",e=>{let t=e.target.checked,i=document.querySelectorAll('input[name^="permissions[0]["]');for(let r of i)r.disabled=t,r.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",()=>{let e=this.roleSelect.value;e&&this.addRoleRow(e)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let i=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),r=Ne(i.data);this.roleContainer.append(r),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:i}=e.dataset,{roleName:r}=e.dataset,o=document.createElement("option");o.value=i,o.textContent=r,this.roleSelect.append(o),t.remove()}};var Kn=class extends b{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),N(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(i=>{this.searchResults.innerHTML=i.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var Xn=class extends b{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",()=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),W(this.$el,"[data-entity-type]","keydown",t=>{if(t.ctrlKey&&t.code==="Enter"){let i=this.$el.closest("form");if(i){i.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),i=t.indexOf(document.activeElement),r=t[i+(e?1:-1)]||t[0];r&&r.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(i=>{this.resultsContainer.innerHTML=i.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),i=e.getAttribute("data-entity-type"),r=e.getAttribute("data-entity-id"),o=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=o?`${i}:${r}`:"";let s=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(r),name:a,link:s};o?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!o)&&(t&&this.confirmSelection(l),o&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Yn=class extends b{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e){this.callback=e,this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Jn=class extends b{setup(){this.container=this.$el,this.name=this.$opts.name,N(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Qn=class extends b{setup(){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(e){pt(e,200)}close(e){dt(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let i of t)(this.isOpen?this.close:this.open)(i);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var ei=class extends b{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let e=Re(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:t}=this.input;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new ze(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let i=Ne(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(i),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var ti=class extends b{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var ni=class extends b{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.uploadButton=this.$refs.uploadButton,this.uploadHint=this.$refs.uploadHint,this.formContainer=this.$refs.formContainer,this.formContainerPlaceholder=this.$refs.formContainerPlaceholder,this.dropzoneContainer=this.$refs.dropzoneContainer,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){N(this.filterTabs,e=>{this.resetAll(),this.filter=e.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",e=>{this.resetListView(),this.loadGallery(),e.preventDefault()}),N(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),W(this.listContainer,".load-more button","click",async e=>{let t=e.target.closest(".load-more");St(t),this.page+=1,await this.loadGallery(),t.remove()}),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",e=>{e.target.src=window.baseUrl("loading_error.png")},!0),N(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),W(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show();let i=t!=="gallery";this.dropzoneContainer.classList.toggle("hidden",i),this.uploadButton.classList.toggle("hidden",i),this.uploadHint.classList.toggle("hidden",i),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!i),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),At(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e,window.$components.init(t);for(let i of[...t.children])this.listContainer.appendChild(i)}setActiveFilterTab(e){for(let t of this.filterTabs){let i=t.dataset.filter===e;t.setAttribute("aria-selected",i?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value=""}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){St(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),i=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,r=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(o=>{o.classList.remove("selected")}),r?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",r),i&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let i=t?{delete:!0}:{},{data:r}=await window.$http.get(`/images/edit/${e}`,i);this.formContainer.innerHTML=r,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer)}};var ii=class extends b{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var ri=class extends b{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var $c=Bo(Sc()),Mc=Bo(Ic()),yi=class{constructor(){this.renderer=new $c.default({html:!0}),this.renderer.use(Mc.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Vp(n,e){return document.createElement(n,e)}function Wp(n,e,t){return document.createElementNS(n,e,t)}function Gp(){return et(document.createDocumentFragment())}function Zp(n){return document.createTextNode(n)}function Kp(n){return document.createComment(n)}function Xp(n,e,t){if(Fe(n)){let i=n;for(;i&&Fe(i);)i=et(i).parent;n=i??n}Fe(e)&&(e=et(e,n)),t&&Fe(t)&&(t=et(t).firstChildNode),n.insertBefore(e,t)}function Yp(n,e){n.removeChild(e)}function Jp(n,e){Fe(e)&&(e=et(e,n)),n.appendChild(e)}function Fc(n){if(Fe(n)){for(;n&&Fe(n);)n=et(n).parent;return n??null}return n.parentNode}function Qp(n){var e;if(Fe(n)){let t=et(n),i=Fc(t);if(i&&t.lastChildNode){let r=Array.from(i.childNodes),o=r.indexOf(t.lastChildNode);return(e=r[o+1])!==null&&e!==void 0?e:null}return null}return n.nextSibling}function ef(n){return n.tagName}function tf(n,e){n.textContent=e}function nf(n){return n.textContent}function rf(n){return n.nodeType===1}function of(n){return n.nodeType===3}function sf(n){return n.nodeType===8}function Fe(n){return n.nodeType===11}function et(n,e){var t,i,r;let o=n;return(t=o.parent)!==null&&t!==void 0||(o.parent=e??null),(i=o.firstChildNode)!==null&&i!==void 0||(o.firstChildNode=n.firstChild),(r=o.lastChildNode)!==null&&r!==void 0||(o.lastChildNode=n.lastChild),o}var wi={createElement:Vp,createElementNS:Wp,createTextNode:Zp,createDocumentFragment:Gp,createComment:Kp,insertBefore:Xp,removeChild:Yp,appendChild:Jp,parentNode:Fc,nextSibling:Qp,tagName:ef,setTextContent:tf,getTextContent:nf,isElement:rf,isText:of,isComment:sf,isDocumentFragment:Fe};function qe(n,e,t,i,r){let o=e===void 0?void 0:e.key;return{sel:n,data:e,children:t,text:i,elm:r,key:o}}var qc=Array.isArray;function Bc(n){return typeof n=="string"||typeof n=="number"||n instanceof String||n instanceof Number}function vo(n){return n===void 0}function ce(n){return n!==void 0}var yo=qe("",{},[],void 0,void 0);function Yt(n,e){var t,i;let r=n.key===e.key,o=((t=n.data)===null||t===void 0?void 0:t.is)===((i=e.data)===null||i===void 0?void 0:i.is),s=n.sel===e.sel,a=!n.sel&&n.sel===e.sel?typeof n.text==typeof e.text:!0;return s&&r&&o&&a}function lf(){throw new Error("The document fragment is not supported on this platform.")}function cf(n,e){return n.isElement(e)}function uf(n,e){return n.isDocumentFragment(e)}function hf(n,e,t){var i;let r={};for(let o=e;o<=t;++o){let s=(i=n[o])===null||i===void 0?void 0:i.key;s!==void 0&&(r[s]=o)}return r}var df=["create","update","remove","destroy","pre","post"];function wo(n,e,t){let i={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=e!==void 0?e:wi;for(let f of df)for(let m of n){let w=m[f];w!==void 0&&i[f].push(w)}function o(f){let m=f.id?"#"+f.id:"",w=f.getAttribute("class"),v=w?"."+w.split(" ").join("."):"";return qe(r.tagName(f).toLowerCase()+m+v,{},[],void 0,f)}function s(f){return qe(void 0,{},[],void 0,f)}function a(f,m){return function(){if(--m===0){let v=r.parentNode(f);r.removeChild(v,f)}}}function l(f,m){var w,v,g,k;let y,_=f.data;if(_!==void 0){let D=(w=_.hook)===null||w===void 0?void 0:w.init;ce(D)&&(D(f),_=f.data)}let x=f.children,S=f.sel;if(S==="!")vo(f.text)&&(f.text=""),f.elm=r.createComment(f.text);else if(S!==void 0){let D=S.indexOf("#"),q=S.indexOf(".",D),L=D>0?D:S.length,I=q>0?q:S.length,H=D!==-1||q!==-1?S.slice(0,Math.min(L,I)):S,R=f.elm=ce(_)&&ce(y=_.ns)?r.createElementNS(y,H,_):r.createElement(H,_);for(L<I&&R.setAttribute("id",S.slice(L+1,I)),q>0&&R.setAttribute("class",S.slice(I+1).replace(/\./g," ")),y=0;y<i.create.length;++y)i.create[y](yo,f);if(qc(x))for(y=0;y<x.length;++y){let ge=x[y];ge!=null&&r.appendChild(R,l(ge,m))}else Bc(f.text)&&r.appendChild(R,r.createTextNode(f.text));let ee=f.data.hook;ce(ee)&&((v=ee.create)===null||v===void 0||v.call(ee,yo,f),ee.insert&&m.push(f))}else if(!((g=t?.experimental)===null||g===void 0)&&g.fragments&&f.children){for(f.elm=((k=r.createDocumentFragment)!==null&&k!==void 0?k:lf)(),y=0;y<i.create.length;++y)i.create[y](yo,f);for(y=0;y<f.children.length;++y){let D=f.children[y];D!=null&&r.appendChild(f.elm,l(D,m))}}else f.elm=r.createTextNode(f.text);return f.elm}function c(f,m,w,v,g,k){for(;v<=g;++v){let y=w[v];y!=null&&r.insertBefore(f,l(y,k),m)}}function u(f){var m,w;let v=f.data;if(v!==void 0){(w=(m=v?.hook)===null||m===void 0?void 0:m.destroy)===null||w===void 0||w.call(m,f);for(let g=0;g<i.destroy.length;++g)i.destroy[g](f);if(f.children!==void 0)for(let g=0;g<f.children.length;++g){let k=f.children[g];k!=null&&typeof k!="string"&&u(k)}}}function h(f,m,w,v){for(var g,k;w<=v;++w){let y,_,x=m[w];if(x!=null)if(ce(x.sel)){u(x),y=i.remove.length+1,_=a(x.elm,y);for(let D=0;D<i.remove.length;++D)i.remove[D](x,_);let S=(k=(g=x?.data)===null||g===void 0?void 0:g.hook)===null||k===void 0?void 0:k.remove;ce(S)?S(x,_):_()}else x.children?(u(x),h(f,x.children,0,x.children.length-1)):r.removeChild(f,x.elm)}}function d(f,m,w,v){let g=0,k=0,y=m.length-1,_=m[0],x=m[y],S=w.length-1,D=w[0],q=w[S],L,I,H,R;for(;g<=y&&k<=S;)_==null?_=m[++g]:x==null?x=m[--y]:D==null?D=w[++k]:q==null?q=w[--S]:Yt(_,D)?(p(_,D,v),_=m[++g],D=w[++k]):Yt(x,q)?(p(x,q,v),x=m[--y],q=w[--S]):Yt(_,q)?(p(_,q,v),r.insertBefore(f,_.elm,r.nextSibling(x.elm)),_=m[++g],q=w[--S]):Yt(x,D)?(p(x,D,v),r.insertBefore(f,x.elm,_.elm),x=m[--y],D=w[++k]):(L===void 0&&(L=hf(m,g,y)),I=L[D.key],vo(I)?r.insertBefore(f,l(D,v),_.elm):(H=m[I],H.sel!==D.sel?r.insertBefore(f,l(D,v),_.elm):(p(H,D,v),m[I]=void 0,r.insertBefore(f,H.elm,_.elm))),D=w[++k]);k<=S&&(R=w[S+1]==null?null:w[S+1].elm,c(f,R,w,k,S,v)),g<=y&&h(f,m,g,y)}function p(f,m,w){var v,g,k,y,_,x,S,D;let q=(v=m.data)===null||v===void 0?void 0:v.hook;(g=q?.prepatch)===null||g===void 0||g.call(q,f,m);let L=m.elm=f.elm;if(f===m)return;if(m.data!==void 0||ce(m.text)&&m.text!==f.text){(k=m.data)!==null&&k!==void 0||(m.data={}),(y=f.data)!==null&&y!==void 0||(f.data={});for(let R=0;R<i.update.length;++R)i.update[R](f,m);(S=(x=(_=m.data)===null||_===void 0?void 0:_.hook)===null||x===void 0?void 0:x.update)===null||S===void 0||S.call(x,f,m)}let I=f.children,H=m.children;vo(m.text)?ce(I)&&ce(H)?I!==H&&d(L,I,H,w):ce(H)?(ce(f.text)&&r.setTextContent(L,""),c(L,null,H,0,H.length-1,w)):ce(I)?h(L,I,0,I.length-1):ce(f.text)&&r.setTextContent(L,""):f.text!==m.text&&(ce(I)&&h(L,I,0,I.length-1),r.setTextContent(L,m.text)),(D=q?.postpatch)===null||D===void 0||D.call(q,f,m)}return function(m,w){let v,g,k,y=[];for(v=0;v<i.pre.length;++v)i.pre[v]();for(cf(r,m)?m=o(m):uf(r,m)&&(m=s(m)),Yt(m,w)?p(m,w,y):(g=m.elm,k=r.parentNode(g),l(w,y),k!==null&&(r.insertBefore(k,w.elm,r.nextSibling(g)),h(k,[m],0,0))),v=0;v<y.length;++v)y[v].data.hook.insert(y[v]);for(v=0;v<i.post.length;++v)i.post[v]();return w}}function xo(n,e,t){if(n.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let i=0;i<e.length;++i){let r=e[i];if(typeof r=="string")continue;let o=r.data;o!==void 0&&xo(o,r.children,r.sel)}}function Jt(n,e){let t=e!==void 0?e:wi,i;if(t.isElement(n)){let r=n.id?"#"+n.id:"",o=n.getAttribute("class"),s=o?"."+o.split(" ").join("."):"",a=t.tagName(n).toLowerCase()+r+s,l={},c={},u={},h=[],d,p,f,m=n.attributes,w=n.childNodes;for(p=0,f=m.length;p<f;p++)d=m[p].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?c[d.slice(5)]=m[p].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=m[p].nodeValue);for(p=0,f=w.length;p<f;p++)h.push(Jt(w[p],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.dataset=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&xo(u,h,a),qe(a,u,h,void 0,n)}else return t.isText(n)?(i=t.getTextContent(n),qe(void 0,void 0,void 0,i,n)):t.isComment(n)?(i=t.getTextContent(n),qe("!",{},[],i,n)):qe("",{},[],void 0,n)}var pf="http://www.w3.org/1999/xlink",ff="http://www.w3.org/XML/1998/namespace";function Pc(n,e){let t,i=e.elm,r=n.data.attrs,o=e.data.attrs;if(!(!r&&!o)&&r!==o){r=r||{},o=o||{};for(t in o){let s=o[t];r[t]!==s&&(s===!0?i.setAttribute(t,""):s===!1?i.removeAttribute(t):t.charCodeAt(0)!==120?i.setAttribute(t,s):t.charCodeAt(3)===58?i.setAttributeNS(ff,t,s):t.charCodeAt(5)===58?i.setAttributeNS(pf,t,s):i.setAttribute(t,s))}for(t in r)t in o||i.removeAttribute(t)}}var ko={create:Pc,update:Pc};var xi;function mf(){return xi||(xi=wo([ko]),xi)}function Oc(n,e){let t=document.createElement("div");t.innerHTML=e,mf()(Jt(n),Jt(t))}var ki=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,i=e.target.closest("a");if(i!==null){e.preventDefault(),window.open(i.getAttribute("href"));return}let r=e.target.closest("[drawio-diagram]");if(r!==null&&t){this.editor.actions.editDrawing(r);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let i=t.cloneNode(!0);this.doc.head.appendChild(i)}}patchWithHtml(e){let{body:t}=this.doc;if(t.children.length===0){let r=document.createElement("div");this.doc.body.append(r)}let i=t.children[0];Oc(i,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};var Le=null,Eo,Co,_o;function So(n){Le.contentWindow.postMessage(JSON.stringify(n),Eo)}function gf(n){_o&&_o(n.data)}function bf(n){So({action:"export",format:"xmlpng",xml:n.xml,spin:"Updating drawing"})}function vf(){Co&&Co().then(n=>{So({action:"load",autosave:1,xml:n})})}function yf(){let n={};window.$events.emitPublic(Le,"editor-drawio::configure",{config:n}),So({action:"configure",config:n})}function Nc(){window.removeEventListener("message",Rc),Le&&document.body.removeChild(Le)}function Rc(n){if(!n.data||n.data.length<1||n.origin!==Eo)return;let e=JSON.parse(n.data);e.event==="init"?vf():e.event==="exit"?Nc():e.event==="save"?bf(e):e.event==="export"?gf(e):e.event==="configure"&&yf()}function Qt(n,e,t){Co=e,_o=t,Le=document.createElement("iframe"),Le.setAttribute("frameborder","0"),window.addEventListener("message",Rc),Le.setAttribute("src",n),Le.setAttribute("class","fullscreen"),Le.style.backgroundColor="#FFFFFF",document.body.appendChild(Le),Eo=new URL(n).origin}async function Ao(n,e){let t={image:n,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function tt(){Nc()}async function Ci(n){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${n}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),tt(),e}}var en,Do,yt,_i,wt,Ei,Be,nt,We,vt,ie,ue,tn,To,nn,Lo,xt,Si,he,ve,Di,Hc,Ai=class{constructor(e){re(this,en);re(this,yt);re(this,wt);re(this,Be);re(this,We);re(this,ie);re(this,tn);re(this,nn);re(this,xt);re(this,he);re(this,Di);this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=T(this,yt,_i).call(this);this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",""),window.$events.emit("editor-markdown-change",""),this.lastContent.html=t,this.lastContent.markdown=e,this.editor.display.patchWithHtml(t)}getContent(){return this.lastContent}showImageInsert(){window.$components.first("image-manager").show(t=>{let i=t.thumbs.display||t.url,o=`[](${t.url})`;T(this,Be,nt).call(this,o,o.length)},"gallery")}insertImage(){let e=``;T(this,Be,nt).call(this,e,e.length-1)}insertLink(){let e=T(this,We,vt).call(this),t=`[${e}]()`,i=e===""?-3:-1;T(this,Be,nt).call(this,t,t.length+i)}showImageManager(){let e=T(this,ie,ue).call(this);window.$components.first("image-manager").show(i=>{T(this,en,Do).call(this,i,e)},"drawio")}showLinkSelector(){let e=T(this,ie,ue).call(this);window.$components.first("entity-selector-popup").show(i=>{let o=`[${T(this,We,vt).call(this,e)||i.name}](${i.link})`;T(this,Be,nt).call(this,o,o.length,e)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=T(this,ie,ue).call(this);Qt(e,()=>Promise.resolve(""),i=>{let r={image:i,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",r).then(o=>{T(this,en,Do).call(this,o.data,t),tt()}).catch(o=>{this.handleDrawingUploadError(o)})})}editDrawing(e){let{drawioUrl:t}=this.editor.config;if(!t)return;let i=T(this,ie,ue).call(this),r=e.getAttribute("drawio-diagram");Qt(t,()=>Ci(r),o=>{let s={image:o,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",s).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=T(this,yt,_i).call(this).split(`
+`};De.text=function(i,e){return Je(i[e].content)};De.html_block=function(i,e){return i[e].content};De.html_inline=function(i,e){return i[e].content};function bt(){this.rules=cd({},De)}bt.prototype.renderAttrs=function(e){var t,n,r;if(!e.attrs)return"";for(r="",t=0,n=e.attrs.length;t<n;t++)r+=" "+Je(e.attrs[t][0])+'="'+Je(e.attrs[t][1])+'"';return r};bt.prototype.renderToken=function(e,t,n){var r,o="",s=!1,a=e[t];return a.hidden?"":(a.block&&a.nesting!==-1&&t&&e[t-1].hidden&&(o+=`
+`),o+=(a.nesting===-1?"</":"<")+a.tag,o+=this.renderAttrs(a),a.nesting===0&&n.xhtmlOut&&(o+=" /"),a.block&&(s=!0,a.nesting===1&&t+1<e.length&&(r=e[t+1],(r.type==="inline"||r.hidden||r.nesting===-1&&r.tag===a.tag)&&(s=!1))),o+=s?`>
+`:">",o)};bt.prototype.renderInline=function(i,e,t){for(var n,r="",o=this.rules,s=0,a=i.length;s<a;s++)n=i[s].type,typeof o[n]<"u"?r+=o[n](i,s,e,t,this):r+=this.renderToken(i,s,e);return r};bt.prototype.renderInlineAsText=function(i,e,t){for(var n="",r=0,o=i.length;r<o;r++)i[r].type==="text"?n+=i[r].content:i[r].type==="image"?n+=this.renderInlineAsText(i[r].children,e,t):i[r].type==="softbreak"&&(n+=`
+`);return n};bt.prototype.render=function(i,e,t){var n,r,o,s="",a=this.rules;for(n=0,r=i.length;n<r;n++)o=i[n].type,o==="inline"?s+=this.renderInline(i[n].children,e,t):typeof a[o]<"u"?s+=a[i[n].type](i,n,e,t,this):s+=this.renderToken(i,n,e,t);return s};aa.exports=bt});var un=E((Fb,ca)=>{"use strict";function Ce(){this.__rules__=[],this.__cache__=null}Ce.prototype.__find__=function(i){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===i)return e;return-1};Ce.prototype.__compile__=function(){var i=this,e=[""];i.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n)})}),i.__cache__={},e.forEach(function(t){i.__cache__[t]=[],i.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||i.__cache__[t].push(n.fn))})})};Ce.prototype.at=function(i,e,t){var n=this.__find__(i),r=t||{};if(n===-1)throw new Error("Parser rule not found: "+i);this.__rules__[n].fn=e,this.__rules__[n].alt=r.alt||[],this.__cache__=null};Ce.prototype.before=function(i,e,t,n){var r=this.__find__(i),o=n||{};if(r===-1)throw new Error("Parser rule not found: "+i);this.__rules__.splice(r,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.after=function(i,e,t,n){var r=this.__find__(i),o=n||{};if(r===-1)throw new Error("Parser rule not found: "+i);this.__rules__.splice(r+1,0,{name:e,enabled:!0,fn:t,alt:o.alt||[]}),this.__cache__=null};Ce.prototype.push=function(i,e,t){var n=t||{};this.__rules__.push({name:i,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null};Ce.prototype.enable=function(i,e){Array.isArray(i)||(i=[i]);var t=[];return i.forEach(function(n){var r=this.__find__(n);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[r].enabled=!0,t.push(n)},this),this.__cache__=null,t};Ce.prototype.enableOnly=function(i,e){Array.isArray(i)||(i=[i]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(i,e)};Ce.prototype.disable=function(i,e){Array.isArray(i)||(i=[i]);var t=[];return i.forEach(function(n){var r=this.__find__(n);if(r<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[r].enabled=!1,t.push(n)},this),this.__cache__=null,t};Ce.prototype.getRules=function(i){return this.__cache__===null&&this.__compile__(),this.__cache__[i]||[]};ca.exports=Ce});var ha=E((qb,ua)=>{"use strict";var hd=/\r\n?|\n/g,dd=/\0/g;ua.exports=function(e){var t;t=e.src.replace(hd,`
+`),t=t.replace(dd,"\uFFFD"),e.src=t}});var pa=E((Bb,da)=>{"use strict";da.exports=function(e){var t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}});var ma=E((Pb,fa)=>{"use strict";fa.exports=function(e){var t=e.tokens,n,r,o;for(r=0,o=t.length;r<o;r++)n=t[r],n.type==="inline"&&e.md.inline.parse(n.content,e.md,e.env,n.children)}});var ba=E((Ob,ga)=>{"use strict";var pd=R().arrayReplaceAt;function fd(i){return/^<a[>\s]/i.test(i)}function md(i){return/^<\/a\s*>/i.test(i)}ga.exports=function(e){var t,n,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b=e.tokens,k;if(e.md.options.linkify){for(n=0,r=b.length;n<r;n++)if(!(b[n].type!=="inline"||!e.md.linkify.pretest(b[n].content)))for(o=b[n].children,f=0,t=o.length-1;t>=0;t--){if(a=o[t],a.type==="link_close"){for(t--;o[t].level!==a.level&&o[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(fd(a.content)&&f>0&&f--,md(a.content)&&f++),!(f>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,k=e.md.linkify.match(u),l=[],p=a.level,d=0,k.length>0&&k[0].index===0&&t>0&&o[t-1].type==="text_special"&&(k=k.slice(1)),c=0;c<k.length;c++)m=k[c].url,y=e.md.normalizeLink(m),e.md.validateLink(y)&&(v=k[c].text,k[c].schema?k[c].schema==="mailto:"&&!/^mailto:/i.test(v)?v=e.md.normalizeLinkText("mailto:"+v).replace(/^mailto:/,""):v=e.md.normalizeLinkText(v):v=e.md.normalizeLinkText("http://"+v).replace(/^http:\/\//,""),h=k[c].index,h>d&&(s=new e.Token("text","",0),s.content=u.slice(d,h),s.level=p,l.push(s)),s=new e.Token("link_open","a",1),s.attrs=[["href",y]],s.level=p++,s.markup="linkify",s.info="auto",l.push(s),s=new e.Token("text","",0),s.content=v,s.level=p,l.push(s),s=new e.Token("link_close","a",-1),s.level=--p,s.markup="linkify",s.info="auto",l.push(s),d=k[c].lastIndex);d<u.length&&(s=new e.Token("text","",0),s.content=u.slice(d),s.level=p,l.push(s)),b[n].children=o=pd(o,t,l)}}}}});var ya=E((Rb,wa)=>{"use strict";var va=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,gd=/\((c|tm|r)\)/i,bd=/\((c|tm|r)\)/ig,vd={c:"\xA9",r:"\xAE",tm:"\u2122"};function wd(i,e){return vd[e.toLowerCase()]}function yd(i){var e,t,n=0;for(e=i.length-1;e>=0;e--)t=i[e],t.type==="text"&&!n&&(t.content=t.content.replace(bd,wd)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function xd(i){var e,t,n=0;for(e=i.length-1;e>=0;e--)t=i[e],t.type==="text"&&!n&&va.test(t.content)&&(t.content=t.content.replace(/\+-/g,"\xB1").replace(/\.{2,}/g,"\u2026").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1\u2014").replace(/(^|\s)--(?=\s|$)/mg,"$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1\u2013")),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}wa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(gd.test(e.tokens[t].content)&&yd(e.tokens[t].children),va.test(e.tokens[t].content)&&xd(e.tokens[t].children))}});var Aa=E((Nb,Sa)=>{"use strict";var xa=R().isWhiteSpace,ka=R().isPunctChar,Ca=R().isMdAsciiPunct,kd=/['"]/,_a=/['"]/g,Ea="\u2019";function hn(i,e,t){return i.slice(0,e)+t+i.slice(e+1)}function Cd(i,e){var t,n,r,o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,_,x;for(w=[],t=0;t<i.length;t++){for(n=i[t],l=i[t].level,b=w.length-1;b>=0&&!(w[b].level<=l);b--);if(w.length=b+1,n.type==="text"){r=n.content,s=0,a=r.length;e:for(;s<a&&(_a.lastIndex=s,o=_a.exec(r),!!o);){if(y=v=!0,s=o.index+1,k=o[0]==="'",u=32,o.index-1>=0)u=r.charCodeAt(o.index-1);else for(b=t-1;b>=0&&!(i[b].type==="softbreak"||i[b].type==="hardbreak");b--)if(i[b].content){u=i[b].content.charCodeAt(i[b].content.length-1);break}if(h=32,s<a)h=r.charCodeAt(s);else for(b=t+1;b<i.length&&!(i[b].type==="softbreak"||i[b].type==="hardbreak");b++)if(i[b].content){h=i[b].content.charCodeAt(0);break}if(d=Ca(u)||ka(String.fromCharCode(u)),p=Ca(h)||ka(String.fromCharCode(h)),f=xa(u),m=xa(h),m?y=!1:p&&(f||d||(y=!1)),f?v=!1:d&&(m||p||(v=!1)),h===34&&o[0]==='"'&&u>=48&&u<=57&&(v=y=!1),y&&v&&(y=d,v=p),!y&&!v){k&&(n.content=hn(n.content,o.index,Ea));continue}if(v){for(b=w.length-1;b>=0&&(c=w[b],!(w[b].level<l));b--)if(c.single===k&&w[b].level===l){c=w[b],k?(_=e.md.options.quotes[2],x=e.md.options.quotes[3]):(_=e.md.options.quotes[0],x=e.md.options.quotes[1]),n.content=hn(n.content,o.index,x),i[c.token].content=hn(i[c.token].content,c.pos,_),s+=x.length-1,c.token===t&&(s+=_.length-1),r=n.content,a=r.length,w.length=b;continue e}}y?w.push({token:t,pos:o.index,single:k,level:l}):v&&k&&(n.content=hn(n.content,o.index,Ea))}}}}Sa.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!kd.test(e.tokens[t].content)||Cd(e.tokens[t].children,e)}});var Ta=E((zb,Da)=>{"use strict";Da.exports=function(e){var t,n,r,o,s,a,l=e.tokens;for(t=0,n=l.length;t<n;t++)if(l[t].type==="inline"){for(r=l[t].children,s=r.length,o=0;o<s;o++)r[o].type==="text_special"&&(r[o].type="text");for(o=a=0;o<s;o++)r[o].type==="text"&&o+1<s&&r[o+1].type==="text"?r[o+1].content=r[o].content+r[o+1].content:(o!==a&&(r[a]=r[o]),a++);o!==a&&(r.length=a)}}});var dn=E((Hb,La)=>{"use strict";function vt(i,e,t){this.type=i,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}vt.prototype.attrIndex=function(e){var t,n,r;if(!this.attrs)return-1;for(t=this.attrs,n=0,r=t.length;n<r;n++)if(t[n][0]===e)return n;return-1};vt.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};vt.prototype.attrSet=function(e,t){var n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r};vt.prototype.attrGet=function(e){var t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n};vt.prototype.attrJoin=function(e,t){var n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+" "+t};La.exports=vt});var Ma=E((Ub,$a)=>{"use strict";var _d=dn();function Ia(i,e,t){this.src=i,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Ia.prototype.Token=_d;$a.exports=Ia});var qa=E((jb,Fa)=>{"use strict";var Ed=un(),Kr=[["normalize",ha()],["block",pa()],["inline",ma()],["linkify",ba()],["replacements",ya()],["smartquotes",Aa()],["text_join",Ta()]];function Xr(){this.ruler=new Ed;for(var i=0;i<Kr.length;i++)this.ruler.push(Kr[i][0],Kr[i][1])}Xr.prototype.process=function(i){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](i)};Xr.prototype.State=Ma();Fa.exports=Xr});var Oa=E((Vb,Pa)=>{"use strict";var Yr=R().isSpace;function Jr(i,e){var t=i.bMarks[e]+i.tShift[e],n=i.eMarks[e];return i.src.slice(t,n)}function Ba(i){var e=[],t=0,n=i.length,r,o=!1,s=0,a="";for(r=i.charCodeAt(t);t<n;)r===124&&(o?(a+=i.substring(s,t-1),s=t):(e.push(a+i.substring(s,t)),a="",s=t+1)),o=r===92,t++,r=i.charCodeAt(t);return e.push(a+i.substring(s)),e}Pa.exports=function(e,t,n,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,_,x;if(t+2>n||(u=t+1,e.sCount[u]<e.blkIndent)||e.sCount[u]-e.blkIndent>=4||(a=e.bMarks[u]+e.tShift[u],a>=e.eMarks[u])||(_=e.src.charCodeAt(a++),_!==124&&_!==45&&_!==58)||a>=e.eMarks[u]||(x=e.src.charCodeAt(a++),x!==124&&x!==45&&x!==58&&!Yr(x))||_===45&&Yr(x))return!1;for(;a<e.eMarks[u];){if(o=e.src.charCodeAt(a),o!==124&&o!==45&&o!==58&&!Yr(o))return!1;a++}for(s=Jr(e,t+1),h=s.split("|"),f=[],l=0;l<h.length;l++){if(m=h[l].trim(),!m){if(l===0||l===h.length-1)continue;return!1}if(!/^:?-+:?$/.test(m))return!1;m.charCodeAt(m.length-1)===58?f.push(m.charCodeAt(0)===58?"center":"right"):m.charCodeAt(0)===58?f.push("left"):f.push("")}if(s=Jr(e,t).trim(),s.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(h=Ba(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),d=h.length,d===0||d!==f.length))return!1;if(r)return!0;for(b=e.parentType,e.parentType="table",w=e.md.block.ruler.getRules("blockquote"),p=e.push("table_open","table",1),p.map=y=[t,0],p=e.push("thead_open","thead",1),p.map=[t,t+1],p=e.push("tr_open","tr",1),p.map=[t,t+1],l=0;l<h.length;l++)p=e.push("th_open","th",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l].trim(),p.children=[],p=e.push("th_close","th",-1);for(p=e.push("tr_close","tr",-1),p=e.push("thead_close","thead",-1),u=t+2;u<n&&!(e.sCount[u]<e.blkIndent);u++){for(k=!1,l=0,c=w.length;l<c;l++)if(w[l](e,u,n,!0)){k=!0;break}if(k||(s=Jr(e,u).trim(),!s)||e.sCount[u]-e.blkIndent>=4)break;for(h=Ba(s),h.length&&h[0]===""&&h.shift(),h.length&&h[h.length-1]===""&&h.pop(),u===t+2&&(p=e.push("tbody_open","tbody",1),p.map=v=[t+2,0]),p=e.push("tr_open","tr",1),p.map=[u,u+1],l=0;l<d;l++)p=e.push("td_open","td",1),f[l]&&(p.attrs=[["style","text-align:"+f[l]]]),p=e.push("inline","",0),p.content=h[l]?h[l].trim():"",p.children=[],p=e.push("td_close","td",-1);p=e.push("tr_close","tr",-1)}return v&&(p=e.push("tbody_close","tbody",-1),v[1]=u),p=e.push("table_close","table",-1),y[1]=u,e.parentType=b,e.line=u,!0}});var Na=E((Wb,Ra)=>{"use strict";Ra.exports=function(e,t,n){var r,o,s;if(e.sCount[t]-e.blkIndent<4)return!1;for(o=r=t+1;r<n;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,o=r;continue}break}return e.line=o,s=e.push("code_block","code",0),s.content=e.getLines(t,o,4+e.blkIndent,!1)+`
+`,s.map=[t,e.line],!0}});var Ha=E((Gb,za)=>{"use strict";za.exports=function(e,t,n,r){var o,s,a,l,c,u,h,d=!1,p=e.bMarks[t]+e.tShift[t],f=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||p+3>f||(o=e.src.charCodeAt(p),o!==126&&o!==96)||(c=p,p=e.skipChars(p,o),s=p-c,s<3)||(h=e.src.slice(c,p),a=e.src.slice(p,f),o===96&&a.indexOf(String.fromCharCode(o))>=0))return!1;if(r)return!0;for(l=t;l++,!(l>=n||(p=c=e.bMarks[l]+e.tShift[l],f=e.eMarks[l],p<f&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(p)===o&&!(e.sCount[l]-e.blkIndent>=4)&&(p=e.skipChars(p,o),!(p-c<s)&&(p=e.skipSpaces(p),!(p<f)))){d=!0;break}return s=e.sCount[t],e.line=l+(d?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,s,!0),u.markup=h,u.map=[t,e.line],!0}});var Va=E((Zb,ja)=>{"use strict";var Ua=R().isSpace;ja.exports=function(e,t,n,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,_,x,S,D,q=e.lineMax,L=e.bMarks[t]+e.tShift[t],I=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(L++)!==62)return!1;if(r)return!0;for(l=p=e.sCount[t]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[t]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f=[e.bMarks[t]],e.bMarks[t]=L;L<I&&(s=e.src.charCodeAt(L),Ua(s));){s===9?p+=4-(p+e.bsCount[t]+(o?1:0))%4:p++;L++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(w?1:0),u=L>=I,b=[e.sCount[t]],e.sCount[t]=p-l,k=[e.tShift[t]],e.tShift[t]=L-e.bMarks[t],x=e.md.block.ruler.getRules("blockquote"),v=e.parentType,e.parentType="blockquote",d=t+1;d<n&&(D=e.sCount[d]<e.blkIndent,L=e.bMarks[d]+e.tShift[d],I=e.eMarks[d],!(L>=I));d++){if(e.src.charCodeAt(L++)===62&&!D){for(l=p=e.sCount[d]+1,e.src.charCodeAt(L)===32?(L++,l++,p++,o=!1,w=!0):e.src.charCodeAt(L)===9?(w=!0,(e.bsCount[d]+p)%4===3?(L++,l++,p++,o=!1):o=!0):w=!1,f.push(e.bMarks[d]),e.bMarks[d]=L;L<I&&(s=e.src.charCodeAt(L),Ua(s));){s===9?p+=4-(p+e.bsCount[d]+(o?1:0))%4:p++;L++}u=L>=I,m.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(w?1:0),b.push(e.sCount[d]),e.sCount[d]=p-l,k.push(e.tShift[d]),e.tShift[d]=L-e.bMarks[d];continue}if(u)break;for(_=!1,a=0,c=x.length;a<c;a++)if(x[a](e,d,n,!0)){_=!0;break}if(_){e.lineMax=d,e.blkIndent!==0&&(f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]-=e.blkIndent);break}f.push(e.bMarks[d]),m.push(e.bsCount[d]),k.push(e.tShift[d]),b.push(e.sCount[d]),e.sCount[d]=-1}for(y=e.blkIndent,e.blkIndent=0,S=e.push("blockquote_open","blockquote",1),S.markup=">",S.map=h=[t,0],e.md.block.tokenize(e,t,d),S=e.push("blockquote_close","blockquote",-1),S.markup=">",e.lineMax=q,e.parentType=v,h[1]=e.line,a=0;a<k.length;a++)e.bMarks[a+t]=f[a],e.tShift[a+t]=k[a],e.sCount[a+t]=b[a],e.bsCount[a+t]=m[a];return e.blkIndent=y,!0}});var Ga=E((Kb,Wa)=>{"use strict";var Sd=R().isSpace;Wa.exports=function(e,t,n,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c++),o!==42&&o!==45&&o!==95))return!1;for(s=1;c<u;){if(a=e.src.charCodeAt(c++),a!==o&&!Sd(a))return!1;a===o&&s++}return s<3?!1:(r||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o))),!0)}});var Ja=E((Xb,Ya)=>{"use strict";var Xa=R().isSpace;function Za(i,e){var t,n,r,o;return n=i.bMarks[e]+i.tShift[e],r=i.eMarks[e],t=i.src.charCodeAt(n++),t!==42&&t!==45&&t!==43||n<r&&(o=i.src.charCodeAt(n),!Xa(o))?-1:n}function Ka(i,e){var t,n=i.bMarks[e]+i.tShift[e],r=n,o=i.eMarks[e];if(r+1>=o||(t=i.src.charCodeAt(r++),t<48||t>57))return-1;for(;;){if(r>=o)return-1;if(t=i.src.charCodeAt(r++),t>=48&&t<=57){if(r-n>=10)return-1;continue}if(t===41||t===46)break;return-1}return r<o&&(t=i.src.charCodeAt(r),!Xa(t))?-1:r}function Ad(i,e){var t,n,r=i.level+2;for(t=e+2,n=i.tokens.length-2;t<n;t++)i.tokens[t].level===r&&i.tokens[t].type==="paragraph_open"&&(i.tokens[t+2].hidden=!0,i.tokens[t].hidden=!0,t+=2)}Ya.exports=function(e,t,n,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,_,x,S,D,q,L,I,H,N,ee,ge,V,Oe=!1,Re=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(r&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(Oe=!0),(I=Ka(e,t))>=0){if(h=!0,N=e.bMarks[t]+e.tShift[t],v=Number(e.src.slice(N,I-1)),Oe&&v!==1)return!1}else if((I=Za(e,t))>=0)h=!1;else return!1;if(Oe&&e.skipSpaces(I)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(I-1),r)return!0;for(m=e.tokens.length,h?(V=e.push("ordered_list_open","ol",1),v!==1&&(V.attrs=[["start",v]])):V=e.push("bullet_list_open","ul",1),V.map=f=[t,0],V.markup=String.fromCharCode(y),k=t,H=!1,ge=e.md.block.ruler.getRules("list"),x=e.parentType,e.parentType="list";k<n;){for(L=I,b=e.eMarks[k],u=w=e.sCount[k]+I-(e.bMarks[t]+e.tShift[t]);L<b;){if(o=e.src.charCodeAt(L),o===9)w+=4-(w+e.bsCount[k])%4;else if(o===32)w++;else break;L++}if(s=L,s>=b?c=1:c=w-u,c>4&&(c=1),l=u+c,V=e.push("list_item_open","li",1),V.markup=String.fromCharCode(y),V.map=d=[t,0],h&&(V.info=e.src.slice(N,I-1)),q=e.tight,D=e.tShift[t],S=e.sCount[t],_=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=s-e.bMarks[t],e.sCount[t]=w,s>=b&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||H)&&(Re=!1),H=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=_,e.tShift[t]=D,e.sCount[t]=S,e.tight=q,V=e.push("list_item_close","li",-1),V.markup=String.fromCharCode(y),k=t=e.line,d[1]=k,s=e.bMarks[t],k>=n||e.sCount[k]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(ee=!1,a=0,p=ge.length;a<p;a++)if(ge[a](e,k,n,!0)){ee=!0;break}if(ee)break;if(h){if(I=Ka(e,k),I<0)break;N=e.bMarks[k]+e.tShift[k]}else if(I=Za(e,k),I<0)break;if(y!==e.src.charCodeAt(I-1))break}return h?V=e.push("ordered_list_close","ol",-1):V=e.push("bullet_list_close","ul",-1),V.markup=String.fromCharCode(y),f[1]=k,e.line=k,e.parentType=x,Re&&Ad(e,m),!0}});var el=E((Yb,Qa)=>{"use strict";var Dd=R().normalizeReference,pn=R().isSpace;Qa.exports=function(e,t,n,r){var o,s,a,l,c,u,h,d,p,f,m,y,v,b,k,w,_=0,x=e.bMarks[t]+e.tShift[t],S=e.eMarks[t],D=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(x)!==91)return!1;for(;++x<S;)if(e.src.charCodeAt(x)===93&&e.src.charCodeAt(x-1)!==92){if(x+1===S||e.src.charCodeAt(x+1)!==58)return!1;break}for(l=e.lineMax,k=e.md.block.ruler.getRules("reference"),f=e.parentType,e.parentType="reference";D<l&&!e.isEmpty(D);D++)if(!(e.sCount[D]-e.blkIndent>3)&&!(e.sCount[D]<0)){for(b=!1,u=0,h=k.length;u<h;u++)if(k[u](e,D,l,!0)){b=!0;break}if(b)break}for(v=e.getLines(t,D,e.blkIndent,!1).trim(),S=v.length,x=1;x<S;x++){if(o=v.charCodeAt(x),o===91)return!1;if(o===93){p=x;break}else o===10?_++:o===92&&(x++,x<S&&v.charCodeAt(x)===10&&_++)}if(p<0||v.charCodeAt(p+1)!==58)return!1;for(x=p+2;x<S;x++)if(o=v.charCodeAt(x),o===10)_++;else if(!pn(o))break;if(m=e.md.helpers.parseLinkDestination(v,x,S),!m.ok||(c=e.md.normalizeLink(m.str),!e.md.validateLink(c)))return!1;for(x=m.pos,_+=m.lines,s=x,a=_,y=x;x<S;x++)if(o=v.charCodeAt(x),o===10)_++;else if(!pn(o))break;for(m=e.md.helpers.parseLinkTitle(v,x,S),x<S&&y!==x&&m.ok?(w=m.str,x=m.pos,_+=m.lines):(w="",x=s,_=a);x<S&&(o=v.charCodeAt(x),!!pn(o));)x++;if(x<S&&v.charCodeAt(x)!==10&&w)for(w="",x=s,_=a;x<S&&(o=v.charCodeAt(x),!!pn(o));)x++;return x<S&&v.charCodeAt(x)!==10||(d=Dd(v.slice(1,p)),!d)?!1:(r||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:w,href:c}),e.parentType=f,e.line=t+_+1),!0)}});var il=E((Jb,tl)=>{"use strict";tl.exports=["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","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var eo=E((Qb,Qr)=>{"use strict";var Td="[a-zA-Z_:][a-zA-Z0-9:._-]*",Ld="[^\"'=<>`\\x00-\\x20]+",Id="'[^']*'",$d='"[^"]*"',Md="(?:"+Ld+"|"+Id+"|"+$d+")",Fd="(?:\\s+"+Td+"(?:\\s*=\\s*"+Md+")?)",nl="<[A-Za-z][A-Za-z0-9\\-]*"+Fd+"*\\s*\\/?>",rl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",qd="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Bd="<[?][\\s\\S]*?[?]>",Pd="<![A-Z]+\\s+[^>]*>",Od="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Rd=new RegExp("^(?:"+nl+"|"+rl+"|"+qd+"|"+Bd+"|"+Pd+"|"+Od+")"),Nd=new RegExp("^(?:"+nl+"|"+rl+")");Qr.exports.HTML_TAG_RE=Rd;Qr.exports.HTML_OPEN_CLOSE_TAG_RE=Nd});var sl=E((ev,ol)=>{"use strict";var zd=il(),Hd=eo().HTML_OPEN_CLOSE_TAG_RE,wt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+zd.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Hd.source+"\\s*$"),/^$/,!1]];ol.exports=function(e,t,n,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(c)!==60)return!1;for(l=e.src.slice(c,u),o=0;o<wt.length&&!wt[o][0].test(l);o++);if(o===wt.length)return!1;if(r)return wt[o][2];if(s=t+1,!wt[o][1].test(l)){for(;s<n&&!(e.sCount[s]<e.blkIndent);s++)if(c=e.bMarks[s]+e.tShift[s],u=e.eMarks[s],l=e.src.slice(c,u),wt[o][1].test(l)){l.length!==0&&s++;break}}return e.line=s,a=e.push("html_block","",0),a.map=[t,s],a.content=e.getLines(t,s,e.blkIndent,!0),!0}});var cl=E((tv,ll)=>{"use strict";var al=R().isSpace;ll.exports=function(e,t,n,r){var o,s,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(o=e.src.charCodeAt(c),o!==35||c>=u))return!1;for(s=1,o=e.src.charCodeAt(++c);o===35&&c<u&&s<=6;)s++,o=e.src.charCodeAt(++c);return s>6||c<u&&!al(o)?!1:(r||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&al(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(s),1),l.markup="########".slice(0,s),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(c,u).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(s),-1),l.markup="########".slice(0,s)),!0)}});var hl=E((iv,ul)=>{"use strict";ul.exports=function(e,t,n){var r,o,s,a,l,c,u,h,d,p=t+1,f,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(f=e.parentType,e.parentType="paragraph";p<n&&!e.isEmpty(p);p++)if(!(e.sCount[p]-e.blkIndent>3)){if(e.sCount[p]>=e.blkIndent&&(c=e.bMarks[p]+e.tShift[p],u=e.eMarks[p],c<u&&(d=e.src.charCodeAt(c),(d===45||d===61)&&(c=e.skipChars(c,d),c=e.skipSpaces(c),c>=u)))){h=d===61?1:2;break}if(!(e.sCount[p]<0)){for(o=!1,s=0,a=m.length;s<a;s++)if(m[s](e,p,n,!0)){o=!0;break}if(o)break}}return h?(r=e.getLines(t,p,e.blkIndent,!1).trim(),e.line=p+1,l=e.push("heading_open","h"+String(h),1),l.markup=String.fromCharCode(d),l.map=[t,e.line],l=e.push("inline","",0),l.content=r,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(h),-1),l.markup=String.fromCharCode(d),e.parentType=f,!0):!1}});var pl=E((nv,dl)=>{"use strict";dl.exports=function(e,t){var n,r,o,s,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),h=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<h&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(r=!1,o=0,s=u.length;o<s;o++)if(u[o](e,c,h,!0)){r=!0;break}if(r)break}return n=e.getLines(t,c,e.blkIndent,!1).trim(),e.line=c,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=n,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var gl=E((rv,ml)=>{"use strict";var fl=dn(),fn=R().isSpace;function Te(i,e,t,n){var r,o,s,a,l,c,u,h;for(this.src=i,this.md=e,this.env=t,this.tokens=n,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,this.result="",o=this.src,h=!1,s=a=c=u=0,l=o.length;a<l;a++){if(r=o.charCodeAt(a),!h)if(fn(r)){c++,r===9?u+=4-u%4:u++;continue}else h=!0;(r===10||a===l-1)&&(r!==10&&a++,this.bMarks.push(s),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),h=!1,c=0,u=0,s=a+1)}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}Te.prototype.push=function(i,e,t){var n=new fl(i,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};Te.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Te.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Te.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!fn(t));e++);return e};Te.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!fn(this.src.charCodeAt(--e)))return e+1;return e};Te.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};Te.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e};Te.prototype.getLines=function(e,t,n,r){var o,s,a,l,c,u,h,d=e;if(e>=t)return"";for(u=new Array(t-e),o=0;d<t;d++,o++){for(s=0,h=l=this.bMarks[d],d+1<t||r?c=this.eMarks[d]+1:c=this.eMarks[d];l<c&&s<n;){if(a=this.src.charCodeAt(l),fn(a))a===9?s+=4-(s+this.bsCount[d])%4:s++;else if(l-h<this.tShift[d])s++;else break;l++}s>n?u[o]=new Array(s-n+1).join(" ")+this.src.slice(l,c):u[o]=this.src.slice(l,c)}return u.join("")};Te.prototype.Token=fl;ml.exports=Te});var vl=E((ov,bl)=>{"use strict";var Ud=un(),mn=[["table",Oa(),["paragraph","reference"]],["code",Na()],["fence",Ha(),["paragraph","reference","blockquote","list"]],["blockquote",Va(),["paragraph","reference","blockquote","list"]],["hr",Ga(),["paragraph","reference","blockquote","list"]],["list",Ja(),["paragraph","reference","blockquote"]],["reference",el()],["html_block",sl(),["paragraph","reference","blockquote"]],["heading",cl(),["paragraph","reference","blockquote"]],["lheading",hl()],["paragraph",pl()]];function gn(){this.ruler=new Ud;for(var i=0;i<mn.length;i++)this.ruler.push(mn[i][0],mn[i][1],{alt:(mn[i][2]||[]).slice()})}gn.prototype.tokenize=function(i,e,t){for(var n,r,o=this.ruler.getRules(""),s=o.length,a=e,l=!1,c=i.md.options.maxNesting;a<t&&(i.line=a=i.skipEmptyLines(a),!(a>=t||i.sCount[a]<i.blkIndent));){if(i.level>=c){i.line=t;break}for(r=0;r<s&&(n=o[r](i,a,t,!1),!n);r++);i.tight=!l,i.isEmpty(i.line-1)&&(l=!0),a=i.line,a<t&&i.isEmpty(a)&&(l=!0,a++,i.line=a)}};gn.prototype.parse=function(i,e,t,n){var r;i&&(r=new this.State(i,e,t,n),this.tokenize(r,r.line,r.lineMax))};gn.prototype.State=gl();bl.exports=gn});var yl=E((sv,wl)=>{"use strict";function jd(i){switch(i){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}wl.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!jd(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var kl=E((av,xl)=>{"use strict";var Vd=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;xl.exports=function(e,t){var n,r,o,s,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(n=e.pos,r=e.posMax,n+3>r)||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47||(o=e.pending.match(Vd),!o)||(s=o[1],a=e.md.linkify.matchAtStart(e.src.slice(n-s.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),c=e.md.normalizeLink(l),!e.md.validateLink(c))?!1:(t||(e.pending=e.pending.slice(0,-s.length),u=e.push("link_open","a",1),u.attrs=[["href",c]],u.markup="linkify",u.info="auto",u=e.push("text","",0),u.content=e.md.normalizeLinkText(l),u=e.push("link_close","a",-1),u.markup="linkify",u.info="auto"),e.pos+=l.length-s.length,!0)}});var _l=E((lv,Cl)=>{"use strict";var Wd=R().isSpace;Cl.exports=function(e,t){var n,r,o,s=e.pos;if(e.src.charCodeAt(s)!==10)return!1;if(n=e.pending.length-1,r=e.posMax,!t)if(n>=0&&e.pending.charCodeAt(n)===32)if(n>=1&&e.pending.charCodeAt(n-1)===32){for(o=n-1;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(s++;s<r&&Wd(e.src.charCodeAt(s));)s++;return e.pos=s,!0}});var Sl=E((cv,El)=>{"use strict";var Gd=R().isSpace,io=[];for(to=0;to<256;to++)io.push(0);var to;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(i){io[i.charCodeAt(0)]=1});El.exports=function(e,t){var n,r,o,s,a,l=e.pos,c=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=c))return!1;if(n=e.src.charCodeAt(l),n===10){for(t||e.push("hardbreak","br",0),l++;l<c&&(n=e.src.charCodeAt(l),!!Gd(n));)l++;return e.pos=l,!0}return s=e.src[l],n>=55296&&n<=56319&&l+1<c&&(r=e.src.charCodeAt(l+1),r>=56320&&r<=57343&&(s+=e.src[l+1],l++)),o="\\"+s,t||(a=e.push("text_special","",0),n<256&&io[n]!==0?a.content=s:a.content=o,a.markup=o,a.info="escape"),e.pos=l+1,!0}});var Dl=E((uv,Al)=>{"use strict";Al.exports=function(e,t){var n,r,o,s,a,l,c,u,h=e.pos,d=e.src.charCodeAt(h);if(d!==96)return!1;for(n=h,h++,r=e.posMax;h<r&&e.src.charCodeAt(h)===96;)h++;if(o=e.src.slice(n,h),c=o.length,e.backticksScanned&&(e.backticks[c]||0)<=n)return t||(e.pending+=o),e.pos+=c,!0;for(a=l=h;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<r&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(s=e.push("code_inline","code",0),s.markup=o,s.content=e.src.slice(h,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=o),e.pos+=c,!0}});var ro=E((hv,no)=>{"use strict";no.exports.tokenize=function(e,t){var n,r,o,s,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(r=e.scanDelims(e.pos,!0),s=r.length,a=String.fromCharCode(c),s<2))return!1;for(s%2&&(o=e.push("text","",0),o.content=a,s--),n=0;n<s;n+=2)o=e.push("text","",0),o.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Tl(i,e){var t,n,r,o,s,a=[],l=e.length;for(t=0;t<l;t++)r=e[t],r.marker===126&&r.end!==-1&&(o=e[r.end],s=i.tokens[r.token],s.type="s_open",s.tag="s",s.nesting=1,s.markup="~~",s.content="",s=i.tokens[o.token],s.type="s_close",s.tag="s",s.nesting=-1,s.markup="~~",s.content="",i.tokens[o.token-1].type==="text"&&i.tokens[o.token-1].content==="~"&&a.push(o.token-1));for(;a.length;){for(t=a.pop(),n=t+1;n<i.tokens.length&&i.tokens[n].type==="s_close";)n++;n--,t!==n&&(s=i.tokens[n],i.tokens[n]=i.tokens[t],i.tokens[t]=s)}}no.exports.postProcess=function(e){var t,n=e.tokens_meta,r=e.tokens_meta.length;for(Tl(e,e.delimiters),t=0;t<r;t++)n[t]&&n[t].delimiters&&Tl(e,n[t].delimiters)}});var so=E((dv,oo)=>{"use strict";oo.exports.tokenize=function(e,t){var n,r,o,s=e.pos,a=e.src.charCodeAt(s);if(t||a!==95&&a!==42)return!1;for(r=e.scanDelims(e.pos,a===42),n=0;n<r.length;n++)o=e.push("text","",0),o.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:r.length,token:e.tokens.length-1,end:-1,open:r.can_open,close:r.can_close});return e.pos+=r.length,!0};function Ll(i,e){var t,n,r,o,s,a,l=e.length;for(t=l-1;t>=0;t--)n=e[t],!(n.marker!==95&&n.marker!==42)&&n.end!==-1&&(r=e[n.end],a=t>0&&e[t-1].end===n.end+1&&e[t-1].marker===n.marker&&e[t-1].token===n.token-1&&e[n.end+1].token===r.token+1,s=String.fromCharCode(n.marker),o=i.tokens[n.token],o.type=a?"strong_open":"em_open",o.tag=a?"strong":"em",o.nesting=1,o.markup=a?s+s:s,o.content="",o=i.tokens[r.token],o.type=a?"strong_close":"em_close",o.tag=a?"strong":"em",o.nesting=-1,o.markup=a?s+s:s,o.content="",a&&(i.tokens[e[t-1].token].content="",i.tokens[e[n.end+1].token].content="",t--))}oo.exports.postProcess=function(e){var t,n=e.tokens_meta,r=e.tokens_meta.length;for(Ll(e,e.delimiters),t=0;t<r;t++)n[t]&&n[t].delimiters&&Ll(e,n[t].delimiters)}});var $l=E((pv,Il)=>{"use strict";var Zd=R().normalizeReference,ao=R().isSpace;Il.exports=function(e,t){var n,r,o,s,a,l,c,u,h,d="",p="",f=e.pos,m=e.posMax,y=e.pos,v=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,s=e.md.helpers.parseLinkLabel(e,e.pos,!0),s<0))return!1;if(l=s+1,l<m&&e.src.charCodeAt(l)===40){for(v=!1,l++;l<m&&(r=e.src.charCodeAt(l),!(!ao(r)&&r!==10));l++);if(l>=m)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(d=e.md.normalizeLink(c.str),e.md.validateLink(d)?l=c.pos:d="",y=l;l<m&&(r=e.src.charCodeAt(l),!(!ao(r)&&r!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&y!==l&&c.ok)for(p=c.str,l=c.pos;l<m&&(r=e.src.charCodeAt(l),!(!ao(r)&&r!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(v=!0),l++}if(v){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?o=e.src.slice(y,l++):l=s+1):l=s+1,o||(o=e.src.slice(a,s)),u=e.env.references[Zd(o)],!u)return e.pos=f,!1;d=u.href,p=u.title}return t||(e.pos=a,e.posMax=s,h=e.push("link_open","a",1),h.attrs=n=[["href",d]],p&&n.push(["title",p]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,h=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Fl=E((fv,Ml)=>{"use strict";var Kd=R().normalizeReference,lo=R().isSpace;Ml.exports=function(e,t){var n,r,o,s,a,l,c,u,h,d,p,f,m,y="",v=e.pos,b=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(c=a+1,c<b&&e.src.charCodeAt(c)===40){for(c++;c<b&&(r=e.src.charCodeAt(c),!(!lo(r)&&r!==10));c++);if(c>=b)return!1;for(m=c,h=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),h.ok&&(y=e.md.normalizeLink(h.str),e.md.validateLink(y)?c=h.pos:y=""),m=c;c<b&&(r=e.src.charCodeAt(c),!(!lo(r)&&r!==10));c++);if(h=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<b&&m!==c&&h.ok)for(d=h.str,c=h.pos;c<b&&(r=e.src.charCodeAt(c),!(!lo(r)&&r!==10));c++);else d="";if(c>=b||e.src.charCodeAt(c)!==41)return e.pos=v,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<b&&e.src.charCodeAt(c)===91?(m=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?s=e.src.slice(m,c++):c=a+1):c=a+1,s||(s=e.src.slice(l,a)),u=e.env.references[Kd(s)],!u)return e.pos=v,!1;y=u.href,d=u.title}return t||(o=e.src.slice(l,a),e.md.inline.parse(o,e.md,e.env,f=[]),p=e.push("image","img",0),p.attrs=n=[["src",y],["alt",""]],p.children=f,p.content=o,d&&n.push(["title",d])),e.pos=c,e.posMax=b,!0}});var Bl=E((mv,ql)=>{"use strict";var Xd=/^([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,Yd=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;ql.exports=function(e,t){var n,r,o,s,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(s=e.src.charCodeAt(c),s===60))return!1;if(s===62)break}return n=e.src.slice(a+1,c),Yd.test(n)?(r=e.md.normalizeLink(n),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(n),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=n.length+2,!0):!1):Xd.test(n)?(r=e.md.normalizeLink("mailto:"+n),e.md.validateLink(r)?(t||(o=e.push("link_open","a",1),o.attrs=[["href",r]],o.markup="autolink",o.info="auto",o=e.push("text","",0),o.content=e.md.normalizeLinkText(n),o=e.push("link_close","a",-1),o.markup="autolink",o.info="auto"),e.pos+=n.length+2,!0):!1):!1}});var Ol=E((gv,Pl)=>{"use strict";var Jd=eo().HTML_TAG_RE;function Qd(i){return/^<a[>\s]/i.test(i)}function ep(i){return/^<\/a\s*>/i.test(i)}function tp(i){var e=i|32;return e>=97&&e<=122}Pl.exports=function(e,t){var n,r,o,s,a=e.pos;return!e.md.options.html||(o=e.posMax,e.src.charCodeAt(a)!==60||a+2>=o)||(n=e.src.charCodeAt(a+1),n!==33&&n!==63&&n!==47&&!tp(n))||(r=e.src.slice(a).match(Jd),!r)?!1:(t||(s=e.push("html_inline","",0),s.content=e.src.slice(a,a+r[0].length),Qd(s.content)&&e.linkLevel++,ep(s.content)&&e.linkLevel--),e.pos+=r[0].length,!0)}});var Hl=E((bv,zl)=>{"use strict";var Rl=jr(),ip=R().has,np=R().isValidEntityCode,Nl=R().fromCodePoint,rp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,op=/^&([a-z][a-z0-9]{1,31});/i;zl.exports=function(e,t){var n,r,o,s,a=e.pos,l=e.posMax;if(e.src.charCodeAt(a)!==38||a+1>=l)return!1;if(n=e.src.charCodeAt(a+1),n===35){if(o=e.src.slice(a).match(rp),o)return t||(r=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0),s.content=np(r)?Nl(r):Nl(65533),s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0}else if(o=e.src.slice(a).match(op),o&&ip(Rl,o[1]))return t||(s=e.push("text_special","",0),s.content=Rl[o[1]],s.markup=o[0],s.info="entity"),e.pos+=o[0].length,!0;return!1}});var Vl=E((vv,jl)=>{"use strict";function Ul(i,e){var t,n,r,o,s,a,l,c,u={},h=e.length;if(h){var d=0,p=-2,f=[];for(t=0;t<h;t++)if(r=e[t],f.push(0),(e[d].marker!==r.marker||p!==r.token-1)&&(d=t),p=r.token,r.length=r.length||0,!!r.close){for(u.hasOwnProperty(r.marker)||(u[r.marker]=[-1,-1,-1,-1,-1,-1]),s=u[r.marker][(r.open?3:0)+r.length%3],n=d-f[d]-1,a=n;n>s;n-=f[n]+1)if(o=e[n],o.marker===r.marker&&o.open&&o.end<0&&(l=!1,(o.close||r.open)&&(o.length+r.length)%3===0&&(o.length%3!==0||r.length%3!==0)&&(l=!0),!l)){c=n>0&&!e[n-1].open?f[n-1]+1:0,f[t]=t-n+c,f[n]=c,r.open=!1,o.end=t,o.close=!1,a=-1,p=-2;break}a!==-1&&(u[r.marker][(r.open?3:0)+(r.length||0)%3]=a)}}}jl.exports=function(e){var t,n=e.tokens_meta,r=e.tokens_meta.length;for(Ul(e,e.delimiters),t=0;t<r;t++)n[t]&&n[t].delimiters&&Ul(e,n[t].delimiters)}});var Gl=E((wv,Wl)=>{"use strict";Wl.exports=function(e){var t,n,r=0,o=e.tokens,s=e.tokens.length;for(t=n=0;t<s;t++)o[t].nesting<0&&r--,o[t].level=r,o[t].nesting>0&&r++,o[t].type==="text"&&t+1<s&&o[t+1].type==="text"?o[t+1].content=o[t].content+o[t+1].content:(t!==n&&(o[n]=o[t]),n++);t!==n&&(o.length=n)}});var Jl=E((yv,Yl)=>{"use strict";var co=dn(),Zl=R().isWhiteSpace,Kl=R().isPunctChar,Xl=R().isMdAsciiPunct;function Kt(i,e,t,n){this.src=i,this.env=t,this.md=e,this.tokens=n,this.tokens_meta=Array(n.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}Kt.prototype.pushPending=function(){var i=new co("text","",0);return i.content=this.pending,i.level=this.pendingLevel,this.tokens.push(i),this.pending="",i};Kt.prototype.push=function(i,e,t){this.pending&&this.pushPending();var n=new co(i,e,t),r=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(r),n};Kt.prototype.scanDelims=function(i,e){var t=i,n,r,o,s,a,l,c,u,h,d=!0,p=!0,f=this.posMax,m=this.src.charCodeAt(i);for(n=i>0?this.src.charCodeAt(i-1):32;t<f&&this.src.charCodeAt(t)===m;)t++;return o=t-i,r=t<f?this.src.charCodeAt(t):32,c=Xl(n)||Kl(String.fromCharCode(n)),h=Xl(r)||Kl(String.fromCharCode(r)),l=Zl(n),u=Zl(r),u?d=!1:h&&(l||c||(d=!1)),l?p=!1:c&&(u||h||(p=!1)),e?(s=d,a=p):(s=d&&(!p||c),a=p&&(!d||h)),{can_open:s,can_close:a,length:o}};Kt.prototype.Token=co;Yl.exports=Kt});var tc=E((xv,ec)=>{"use strict";var Ql=un(),uo=[["text",yl()],["linkify",kl()],["newline",_l()],["escape",Sl()],["backticks",Dl()],["strikethrough",ro().tokenize],["emphasis",so().tokenize],["link",$l()],["image",Fl()],["autolink",Bl()],["html_inline",Ol()],["entity",Hl()]],ho=[["balance_pairs",Vl()],["strikethrough",ro().postProcess],["emphasis",so().postProcess],["fragments_join",Gl()]];function Xt(){var i;for(this.ruler=new Ql,i=0;i<uo.length;i++)this.ruler.push(uo[i][0],uo[i][1]);for(this.ruler2=new Ql,i=0;i<ho.length;i++)this.ruler2.push(ho[i][0],ho[i][1])}Xt.prototype.skipToken=function(i){var e,t,n=i.pos,r=this.ruler.getRules(""),o=r.length,s=i.md.options.maxNesting,a=i.cache;if(typeof a[n]<"u"){i.pos=a[n];return}if(i.level<s)for(t=0;t<o&&(i.level++,e=r[t](i,!0),i.level--,!e);t++);else i.pos=i.posMax;e||i.pos++,a[n]=i.pos};Xt.prototype.tokenize=function(i){for(var e,t,n=this.ruler.getRules(""),r=n.length,o=i.posMax,s=i.md.options.maxNesting;i.pos<o;){if(i.level<s)for(t=0;t<r&&(e=n[t](i,!1),!e);t++);if(e){if(i.pos>=o)break;continue}i.pending+=i.src[i.pos++]}i.pending&&i.pushPending()};Xt.prototype.parse=function(i,e,t,n){var r,o,s,a=new this.State(i,e,t,n);for(this.tokenize(a),o=this.ruler2.getRules(""),s=o.length,r=0;r<s;r++)o[r](a)};Xt.prototype.State=Jl();ec.exports=Xt});var nc=E((kv,ic)=>{"use strict";ic.exports=function(i){var e={};i=i||{},e.src_Any=Wr().source,e.src_Cc=Gr().source,e.src_Z=Zr().source,e.src_P=on().source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");var t="[><\uFF5C]";return e.src_pseudo_letter="(?:(?!"+t+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+t+"|"+e.src_ZPCc+")(?!"+(i["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+t+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(i["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+t+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}});var lc=E((Cv,ac)=>{"use strict";function po(i){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(n){i[n]=t[n]})}),i}function vn(i){return Object.prototype.toString.call(i)}function sp(i){return vn(i)==="[object String]"}function ap(i){return vn(i)==="[object Object]"}function lp(i){return vn(i)==="[object RegExp]"}function rc(i){return vn(i)==="[object Function]"}function cp(i){return i.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var sc={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function up(i){return Object.keys(i||{}).reduce(function(e,t){return e||sc.hasOwnProperty(t)},!1)}var hp={"http:":{validate:function(i,e,t){var n=i.slice(e);return t.re.http||(t.re.http=new RegExp("^\\/\\/"+t.re.src_auth+t.re.src_host_port_strict+t.re.src_path,"i")),t.re.http.test(n)?n.match(t.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(i,e,t){var n=i.slice(e);return t.re.no_http||(t.re.no_http=new RegExp("^"+t.re.src_auth+"(?:localhost|(?:(?:"+t.re.src_domain+")\\.)+"+t.re.src_domain_root+")"+t.re.src_port+t.re.src_host_terminator+t.re.src_path,"i")),t.re.no_http.test(n)?e>=3&&i[e-3]===":"||e>=3&&i[e-3]==="/"?0:n.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(i,e,t){var n=i.slice(e);return t.re.mailto||(t.re.mailto=new RegExp("^"+t.re.src_email_name+"@"+t.re.src_host_strict,"i")),t.re.mailto.test(n)?n.match(t.re.mailto)[0].length:0}}},dp="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",pp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function fp(i){i.__index__=-1,i.__text_cache__=""}function mp(i){return function(e,t){var n=e.slice(t);return i.test(n)?n.match(i)[0].length:0}}function oc(){return function(i,e){e.normalize(i)}}function bn(i){var e=i.re=nc()(i.__opts__),t=i.__tlds__.slice();i.onCompile(),i.__tlds_replaced__||t.push(dp),t.push(e.src_xn),e.src_tlds=t.join("|");function n(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(n(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(n(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(n(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(n(e.tpl_host_fuzzy_test),"i");var r=[];i.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(i.__schemas__).forEach(function(a){var l=i.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(i.__compiled__[a]=c,ap(l)){lp(l.validate)?c.validate=mp(l.validate):rc(l.validate)?c.validate=l.validate:o(a,l),rc(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=oc();return}if(sp(l)){r.push(a);return}o(a,l)}}),r.forEach(function(a){i.__compiled__[i.__schemas__[a]]&&(i.__compiled__[a].validate=i.__compiled__[i.__schemas__[a]].validate,i.__compiled__[a].normalize=i.__compiled__[i.__schemas__[a]].normalize)}),i.__compiled__[""]={validate:null,normalize:oc()};var s=Object.keys(i.__compiled__).filter(function(a){return a.length>0&&i.__compiled__[a]}).map(cp).join("|");i.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","i"),i.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+s+")","ig"),i.re.schema_at_start=RegExp("^"+i.re.schema_search.source,"i"),i.re.pretest=RegExp("("+i.re.schema_test.source+")|("+i.re.host_fuzzy_test.source+")|@","i"),fp(i)}function gp(i,e){var t=i.__index__,n=i.__last_index__,r=i.__text_cache__.slice(t,n);this.schema=i.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=n+e,this.raw=r,this.text=r,this.url=r}function fo(i,e){var t=new gp(i,e);return i.__compiled__[t.schema].normalize(t,i),t}function me(i,e){if(!(this instanceof me))return new me(i,e);e||up(i)&&(e=i,i={}),this.__opts__=po({},sc,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=po({},hp,i),this.__compiled__={},this.__tlds__=pp,this.__tlds_replaced__=!1,this.re={},bn(this)}me.prototype.add=function(e,t){return this.__schemas__[e]=t,bn(this),this};me.prototype.set=function(e){return this.__opts__=po(this.__opts__,e),this};me.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,r,o,s,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(o=this.testSchemaAt(e,t[2],l.lastIndex),o){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=n.index+n[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(r=e.match(this.re.email_fuzzy))!==null&&(s=r.index+r[1].length,a=r.index+r[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};me.prototype.pretest=function(e){return this.re.pretest.test(e)};me.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};me.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(fo(this,t)),t=this.__last_index__);for(var r=t?e.slice(t):e;this.test(r);)n.push(fo(this,t)),r=r.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};me.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;var t=this.re.schema_at_start.exec(e);if(!t)return null;var n=this.testSchemaAt(e,t[2],t[0].length);return n?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+n,fo(this,0)):null};me.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(n,r,o){return n!==o[r-1]}).reverse(),bn(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,bn(this),this)};me.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};me.prototype.onCompile=function(){};ac.exports=me});var gc={};St(gc,{decode:()=>vo,default:()=>_p,encode:()=>wo,toASCII:()=>mc,toUnicode:()=>fc,ucs2decode:()=>bo,ucs2encode:()=>dc});function Ve(i){throw new RangeError(yp[i])}function xp(i,e){let t=[],n=i.length;for(;n--;)t[n]=e(i[n]);return t}function hc(i,e){let t=i.split("@"),n="";t.length>1&&(n=t[0]+"@",i=t[1]),i=i.replace(wp,".");let r=i.split("."),o=xp(r,e).join(".");return n+o}function bo(i){let e=[],t=0,n=i.length;for(;t<n;){let r=i.charCodeAt(t++);if(r>=55296&&r<=56319&&t<n){let o=i.charCodeAt(t++);(o&64512)==56320?e.push(((r&1023)<<10)+(o&1023)+65536):(e.push(r),t--)}else e.push(r)}return e}var uc,bp,vp,wp,yp,mo,Le,go,dc,kp,cc,pc,vo,wo,fc,mc,Cp,_p,bc=Au(()=>{"use strict";uc="-",bp=/^xn--/,vp=/[^\0-\x7F]/,wp=/[\x2E\u3002\uFF0E\uFF61]/g,yp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},mo=36-1,Le=Math.floor,go=String.fromCharCode;dc=i=>String.fromCodePoint(...i),kp=function(i){return i>=48&&i<58?26+(i-48):i>=65&&i<91?i-65:i>=97&&i<123?i-97:36},cc=function(i,e){return i+22+75*(i<26)-((e!=0)<<5)},pc=function(i,e,t){let n=0;for(i=t?Le(i/700):i>>1,i+=Le(i/e);i>mo*26>>1;n+=36)i=Le(i/mo);return Le(n+(mo+1)*i/(i+38))},vo=function(i){let e=[],t=i.length,n=0,r=128,o=72,s=i.lastIndexOf(uc);s<0&&(s=0);for(let a=0;a<s;++a)i.charCodeAt(a)>=128&&Ve("not-basic"),e.push(i.charCodeAt(a));for(let a=s>0?s+1:0;a<t;){let l=n;for(let u=1,h=36;;h+=36){a>=t&&Ve("invalid-input");let d=kp(i.charCodeAt(a++));d>=36&&Ve("invalid-input"),d>Le((2147483647-n)/u)&&Ve("overflow"),n+=d*u;let p=h<=o?1:h>=o+26?26:h-o;if(d<p)break;let f=36-p;u>Le(2147483647/f)&&Ve("overflow"),u*=f}let c=e.length+1;o=pc(n-l,c,l==0),Le(n/c)>2147483647-r&&Ve("overflow"),r+=Le(n/c),n%=c,e.splice(n++,0,r)}return String.fromCodePoint(...e)},wo=function(i){let e=[];i=bo(i);let t=i.length,n=128,r=0,o=72;for(let l of i)l<128&&e.push(go(l));let s=e.length,a=s;for(s&&e.push(uc);a<t;){let l=2147483647;for(let u of i)u>=n&&u<l&&(l=u);let c=a+1;l-n>Le((2147483647-r)/c)&&Ve("overflow"),r+=(l-n)*c,n=l;for(let u of i)if(u<n&&++r>2147483647&&Ve("overflow"),u===n){let h=r;for(let d=36;;d+=36){let p=d<=o?1:d>=o+26?26:d-o;if(h<p)break;let f=h-p,m=36-p;e.push(go(cc(p+f%m,0))),h=Le(f/m)}e.push(go(cc(h,0))),o=pc(r,c,a===s),r=0,++a}++r,++n}return e.join("")},fc=function(i){return hc(i,function(e){return bp.test(e)?vo(e.slice(4).toLowerCase()):e})},mc=function(i){return hc(i,function(e){return vp.test(e)?"xn--"+wo(e):e})},Cp={version:"2.1.0",ucs2:{decode:bo,encode:dc},decode:vo,encode:wo,toASCII:mc,toUnicode:fc},_p=Cp});var wc=E((_v,vc)=>{"use strict";vc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}});var xc=E((Ev,yc)=>{"use strict";yc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}}});var Cc=E((Sv,kc)=>{"use strict";kc.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}});var Ac=E((Av,Sc)=>{"use strict";var Yt=R(),Ep=sa(),Sp=la(),Ap=qa(),Dp=vl(),Tp=tc(),Lp=lc(),Qe=Vr(),_c=(bc(),Du(gc)),Ip={default:wc(),zero:xc(),commonmark:Cc()},$p=/^(vbscript|javascript|file|data):/,Mp=/^data:image\/(gif|png|jpeg|webp);/;function Fp(i){var e=i.trim().toLowerCase();return $p.test(e)?!!Mp.test(e):!0}var Ec=["http:","https:","mailto:"];function qp(i){var e=Qe.parse(i,!0);if(e.hostname&&(!e.protocol||Ec.indexOf(e.protocol)>=0))try{e.hostname=_c.toASCII(e.hostname)}catch{}return Qe.encode(Qe.format(e))}function Bp(i){var e=Qe.parse(i,!0);if(e.hostname&&(!e.protocol||Ec.indexOf(e.protocol)>=0))try{e.hostname=_c.toUnicode(e.hostname)}catch{}return Qe.decode(Qe.format(e),Qe.decode.defaultChars+"%")}function be(i,e){if(!(this instanceof be))return new be(i,e);e||Yt.isString(i)||(e=i||{},i="default"),this.inline=new Tp,this.block=new Dp,this.core=new Ap,this.renderer=new Sp,this.linkify=new Lp,this.validateLink=Fp,this.normalizeLink=qp,this.normalizeLinkText=Bp,this.utils=Yt,this.helpers=Yt.assign({},Ep),this.options={},this.configure(i),e&&this.set(e)}be.prototype.set=function(i){return Yt.assign(this.options,i),this};be.prototype.configure=function(i){var e=this,t;if(Yt.isString(i)&&(t=i,i=Ip[t],!i))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!i)throw new Error("Wrong `markdown-it` preset, can't be empty");return i.options&&e.set(i.options),i.components&&Object.keys(i.components).forEach(function(n){i.components[n].rules&&e[n].ruler.enableOnly(i.components[n].rules),i.components[n].rules2&&e[n].ruler2.enableOnly(i.components[n].rules2)}),this};be.prototype.enable=function(i,e){var t=[];Array.isArray(i)||(i=[i]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.enable(i,!0))},this),t=t.concat(this.inline.ruler2.enable(i,!0));var n=i.filter(function(r){return t.indexOf(r)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this};be.prototype.disable=function(i,e){var t=[];Array.isArray(i)||(i=[i]),["core","block","inline"].forEach(function(r){t=t.concat(this[r].ruler.disable(i,!0))},this),t=t.concat(this.inline.ruler2.disable(i,!0));var n=i.filter(function(r){return t.indexOf(r)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this};be.prototype.use=function(i){var e=[this].concat(Array.prototype.slice.call(arguments,1));return i.apply(i,e),this};be.prototype.parse=function(i,e){if(typeof i!="string")throw new Error("Input data should be a String");var t=new this.core.State(i,this,e);return this.core.process(t),t.tokens};be.prototype.render=function(i,e){return e=e||{},this.renderer.render(this.parse(i,e),this.options,e)};be.prototype.parseInline=function(i,e){var t=new this.core.State(i,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};be.prototype.renderInline=function(i,e){return e=e||{},this.renderer.render(this.parseInline(i,e),this.options,e)};Sc.exports=be});var Tc=E((Dv,Dc)=>{"use strict";Dc.exports=Ac()});var Fc=E((Tv,Mc)=>{var yo=!0,Ic=!1,$c=!1;Mc.exports=function(i,e){e&&(yo=!e.enabled,Ic=!!e.label,$c=!!e.labelAfter),i.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,r=2;r<n.length;r++)Op(n,r)&&(Rp(n[r],t.Token),Lc(n[r-2],"class","task-list-item"+(yo?"":" enabled")),Lc(n[Pp(n,r-2)],"class","contains-task-list"))})};function Lc(i,e,t){var n=i.attrIndex(e),r=[e,t];n<0?i.attrPush(r):i.attrs[n]=r}function Pp(i,e){for(var t=i[e].level-1,n=e-1;n>=0;n--)if(i[n].level===t)return n;return-1}function Op(i,e){return jp(i[e])&&Vp(i[e-1])&&Wp(i[e-2])&&Gp(i[e])}function Rp(i,e){if(i.children.unshift(Np(i,e)),i.children[1].content=i.children[1].content.slice(3),i.content=i.content.slice(3),Ic)if($c){i.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);i.children[0].content=i.children[0].content.slice(0,-1)+' id="'+t+'">',i.children.push(Up(i.content,t,e))}else i.children.unshift(zp(e)),i.children.push(Hp(e))}function Np(i,e){var t=new e("html_inline","",0),n=yo?' disabled="" ':"";return i.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+n+'type="checkbox">':(i.content.indexOf("[x] ")===0||i.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+n+'type="checkbox">'),t}function zp(i){var e=new i("html_inline","",0);return e.content="<label>",e}function Hp(i){var e=new i("html_inline","",0);return e.content="</label>",e}function Up(i,e,t){var n=new t("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+e+'">'+i+"</label>",n.attrs=[{for:e}],n}function jp(i){return i.type==="inline"}function Vp(i){return i.type==="paragraph_open"}function Wp(i){return i.type==="list_item_open"}function Gp(i){return i.content.indexOf("[ ] ")===0||i.content.indexOf("[x] ")===0||i.content.indexOf("[X] ")===0}});var ur={};St(ur,{emit:()=>lr,emitPublic:()=>$u,error:()=>cr,listen:()=>Iu,showResponseError:()=>qu,showValidationErrors:()=>Fu,success:()=>Mu});var ri={},Lu=[];function lr(i,e){Lu.push({name:i,data:e});let t=ri[i]||[];for(let n of t)n(e)}function Iu(i,e){typeof ri[i]>"u"&&(ri[i]=[]),ri[i].push(e)}function $u(i,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});i.dispatchEvent(n)}function Mu(i){lr("success",i)}function cr(i){lr("error",i)}function Fu(i){if(i.status&&i.status===422&&i.data){let e=Object.values(i.data).flat().join(`
+`);cr(e)}}function qu(i){i.status&&i.status>=400&&i.data&&i.data.message&&cr(i.data.message)}var hr={};St(hr,{HttpError:()=>oi,createXMLHttpRequest:()=>Pu,delete:()=>Hu,get:()=>Ou,patch:()=>zu,post:()=>Ru,put:()=>Nu});async function Bu(i){if(i.status===204)return null;let t=(i.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?i.json():i.text()}var oi=class extends Error{constructor(e,t){super(e.statusText),this.data=t,this.headers=e.headers,this.redirected=e.redirected,this.status=e.status,this.statusText=e.statusText,this.url=e.url,this.original=e}};function Pu(i,e,t={}){let n=document.querySelector("meta[name=token]").getAttribute("content"),r=new XMLHttpRequest;for(let[o,s]of Object.entries(t))r.addEventListener(o,s.bind(r));return r.open(i,e),r.withCredentials=!0,r.setRequestHeader("X-CSRF-TOKEN",n),r}async function No(i,e={}){let t=i;if(t.startsWith("http")||(t=window.baseUrl(t)),e.params){let l=new URL(t);for(let c of Object.keys(e.params)){let u=e.params[c];typeof u<"u"&&u!==null&&l.searchParams.set(c,u)}t=l.toString()}let n=document.querySelector("meta[name=token]").getAttribute("content"),r={...e,credentials:"same-origin"};r.headers={...r.headers||{},baseURL:window.baseUrl(""),"X-CSRF-TOKEN":n};let o=await fetch(t,r),s=await Bu(o),a={data:s,headers:o.headers,redirected:o.redirected,status:o.status,statusText:o.statusText,url:o.url,original:o};if(!o.ok)throw new oi(o,s);return a}async function si(i,e,t=null){let n={method:i,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(n.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},n.body=JSON.stringify(t)),t instanceof FormData&&i!=="post"&&(t.append("_method",i),n.method="post"),No(e,n)}async function Ou(i,e={}){return No(i,{method:"GET",params:e})}async function Ru(i,e=null){return si("POST",i,e)}async function Nu(i,e=null){return si("PUT",i,e)}async function zu(i,e=null){return si("PATCH",i,e)}async function Hu(i,e=null){return si("DELETE",i,e)}var dr=class{constructor(){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),r=t.getAttribute("value");this.store.set(n,r)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let r=this.getTransText(e);return this.parsePlural(r,t,n)}parsePlural(e,t,n){let r=e.split("|"),o=/^{([0-9]+)}/,s=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of r){let c=l.match(o);if(c!==null&&Number(c[1])===t){a=l.replace(o,"").trim();break}let u=l.match(s);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(s,"").trim();break}}return a===null&&r.length>1&&(a=t===1?r[0]:r[1]),a===null&&(a=r[0]),this.performReplacements(a,n)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let n=e.match(/:(\S+)/g);if(n===null)return e;let r=e;return n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(r=r.replace(o,t[s]))}),r}},zo=dr;var br={};St(br,{first:()=>Wu,firstOnElement:()=>Zu,get:()=>Gu,init:()=>mr,register:()=>gr});function pr(i){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=i.split("-");return t[0]+t.slice(1).map(e).join("")}function Ho(i){return i.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var At={},Uo={},fr=new WeakMap;function Uu(i,e){let t={},n={},r=`${i}@`,o=`[refs*="${r}"]`,s=[...e.querySelectorAll(o)];e.matches(o)&&s.push(e);for(let a of s){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(r)).map(c=>c.replace(r,"")).map(pr);for(let c of l)t[c]=a,typeof n[c]>"u"&&(n[c]=[]),n[c].push(a)}return{refs:t,manyRefs:n}}function ju(i,e){let t={},n=`option:${i}:`;for(let{name:r,value:o}of e.attributes)if(r.startsWith(n)){let s=r.replace(n,"");t[pr(s)]=o||""}return t}function Vu(i,e){let t=Uo[i];if(t===void 0)return;let n;try{n=new t,n.$name=i,n.$el=e;let o=Uu(i,e);n.$refs=o.refs,n.$manyRefs=o.manyRefs,n.$opts=ju(i,e),n.setup()}catch(o){console.error("Failed to create component",o,i,e)}typeof At[i]>"u"&&(At[i]=[]),At[i].push(n);let r=fr.get(e)||{};r[i]=n,fr.set(e,r)}function mr(i=document){let e=i.querySelectorAll("[component],[components]");for(let t of e){let n=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let r of n)Vu(r,t)}}function gr(i){let e=Object.keys(i);for(let t of e)Uo[Ho(t)]=i[t]}function Wu(i){return(At[i]||[null])[0]}function Gu(i){return At[i]||[]}function Zu(i,e){return(fr.get(i)||{})[e]||null}var Bo={};St(Bo,{AddRemoveRows:()=>li,AjaxDeleteRow:()=>ci,AjaxForm:()=>ui,Attachments:()=>hi,AttachmentsList:()=>di,AutoSubmit:()=>fi,AutoSuggest:()=>pi,BackToTop:()=>mi,BookSort:()=>Mi,ChapterContents:()=>qi,CodeEditor:()=>Bi,CodeHighlighter:()=>Pi,CodeTextarea:()=>Oi,Collapsible:()=>Ri,ConfirmDialog:()=>Ni,CustomCheckbox:()=>zi,DetailsHighlighter:()=>Hi,Dropdown:()=>Ui,DropdownSearch:()=>ji,Dropzone:()=>Vi,EditorToolbox:()=>Wi,EntityPermissions:()=>Gi,EntitySearch:()=>Zi,EntitySelector:()=>Ki,EntitySelectorPopup:()=>Xi,EventEmitSelect:()=>Yi,ExpandToggle:()=>Ji,GlobalSearch:()=>Qi,HeaderMobileToggle:()=>en,ImageManager:()=>tn,ImagePicker:()=>nn,ListSortControl:()=>rn,MarkdownEditor:()=>In,NewUserPassword:()=>$n,Notification:()=>Mn,OptionalInput:()=>Fn,PageComment:()=>qn,PageComments:()=>Bn,PageDisplay:()=>Pn,PageEditor:()=>On,PagePicker:()=>Nn,PermissionsTable:()=>zn,Pointer:()=>Hn,Popup:()=>Un,SettingAppColorScheme:()=>jn,SettingColorPicker:()=>Vn,SettingHomepageControl:()=>Wn,ShelfSort:()=>Gn,ShortcutInput:()=>Kn,Shortcuts:()=>Zn,SortableList:()=>Xn,SubmitOnChange:()=>Yn,Tabs:()=>Jn,TagManager:()=>Qn,TemplateManager:()=>er,ToggleSwitch:()=>tr,TriLayout:()=>ir,UserSelect:()=>nr,WebhookEvents:()=>rr,WysiwygEditor:()=>ar});function _e(i,e={},t=[]){let n=document.createElement(i);for(let[r,o]of Object.entries(e))o===null?n.removeAttribute(r):n.setAttribute(r,o);for(let r of t)typeof r=="string"?n.append(document.createTextNode(r)):n.append(r);return n}function vr(i,e){let t=document.querySelectorAll(i);for(let n of t)e(n)}function ai(i,e,t){for(let n of e)i.addEventListener(n,t)}function O(i,e){Array.isArray(i)||(i=[i]);for(let t of i)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function jo(i,e,t){Array.isArray(e)||(e=[e]);let n=r=>{r.key===i&&t(r)};e.forEach(r=>r.addEventListener("keydown",n))}function st(i,e){jo("Enter",i,e)}function Vo(i,e){jo("Escape",i,e)}function Z(i,e,t,n){i.addEventListener(t,r=>{let o=r.target.closest(e);o&&n.call(o,r,o)})}function Wo(i,e){let t=document.querySelectorAll(i);e=e.toLowerCase();for(let n of t)if(n.textContent.toLowerCase().includes(e))return n;return null}function Dt(i){i.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function at(){let i=document.createElement("div");return i.classList.add("loading-container"),i.innerHTML="<div></div><div></div><div></div>",i}function Tt(i){let e=i.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ee(i){let e=document.createElement("div");return e.innerHTML=i,window.$components.init(e),e.children[0]}function Ne(i,e,t){let n;return function(...o){let s=this,a=function(){n=null,t||i.apply(s,o)},l=t&&!n;clearTimeout(n),n=setTimeout(a,e),l&&i.apply(s,o)}}function yr(i){if(!i)return;i.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(i).getPropertyValue("background-color");i.style.backgroundColor=e,setTimeout(()=>{i.classList.add("selectFade"),i.style.backgroundColor=t},10),setTimeout(()=>{i.classList.remove("selectFade"),i.style.backgroundColor=""},3e3)}function Go(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zo(){let i=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${i()+i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}var g=class{constructor(){se(this,"$name","");se(this,"$el",null);se(this,"$refs",{});se(this,"$manyRefs",{});se(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,r=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(r)}};var li=class extends g{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),Z(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.$components.init(e)}setClonedInputNames(e){let t=Zo(),n=e.querySelectorAll('[name*="randrowid"]');for(let r of n)r.name=r.name.split("randrowid").join(t)}};var ci=class extends g{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,O(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(()=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var ui=class extends g{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}st(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>O(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var hi=class extends g{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.linksContainer=this.$refs.linksContainer,this.listPanel=this.$refs.listPanel,this.attachLinkButton=this.$refs.attachLinkButton,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-upload-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",()=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),r=JSON.parse(n);window.$events.emit("editor::insert",{html:r["text/html"],markdown:r["text/plain"]})}),this.attachLinkButton.addEventListener("click",()=>{this.showSection("links")})}showSection(e){let t={links:this.linksContainer,edit:this.editContainer,list:this.listContainer};for(let[n,r]of Object.entries(t))r.toggleAttribute("hidden",n!==e)}reloadList(){this.stopEdit(),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.listPanel.innerHTML=e.data,window.$components.init(this.listPanel)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.showSection("edit"),Dt(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.showSection("list")}};var di=class extends g{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href+="?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var Lt,xr,It,kr,ze=class{constructor(e,t=null,n=null){re(this,Lt);re(this,It);this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",T(this,Lt,xr).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",T(this,Lt,xr).bind(this))}focusNext(){let e=T(this,It,kr).call(this),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=T(this,It,kr).call(this),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}};Lt=new WeakSet,xr=function(e){e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))},It=new WeakSet,kr=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"],[disabled]),input:not([type=hidden])';for(let n of this.containers)e.push(...n.querySelectorAll(t));return e};var Cr={},pi=class extends g{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){new ze(this.list,()=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault(),this.selectSuggestion(t.target.textContent)}).shareHandlingToEl(this.input),Z(this.list,".text-item","click",(t,n)=>{this.selectSuggestion(n.textContent)}),this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.input.addEventListener("keydown",t=>{t.key==="Tab"&&this.hideSuggestions()})}selectSuggestion(e){this.input.value=e,this.lastPopulated=Date.now(),this.input.focus(),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hideSuggestions()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),r=(await this.loadSuggestions(t,e)).filter(o=>t===""||o.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(r)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let n={search:e,name:t},r=`${this.url}:${JSON.stringify(n)}`;if(Cr[r])return Cr[r];let o=await window.$http.get(this.url,n);return Cr[r]=o.data,o.data}displaySuggestions(e){if(e.length===0){this.hideSuggestions();return}this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${Go(t)}</div></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll(".text-item"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var fi=class extends g{setup(){this.form=this.$el,this.form.submit()}};var mi=class extends g{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,n=300,r=Date.now(),o=this.targetElem.getBoundingClientRect().top;function s(){let a=1-(Date.now()-r)/n,l=Math.abs(a*o);a>0?(t.scrollTop=l,requestAnimationFrame(s.bind(this))):t.scrollTop=e}requestAnimationFrame(s.bind(this))}};function Ko(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ae(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ko(Object(t),!0).forEach(function(n){Ku(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ko(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ki(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ki=function(e){return typeof e}:ki=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ki(i)}function Ku(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ke(){return ke=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},ke.apply(this,arguments)}function Xu(i,e){if(i==null)return{};var t={},n=Object.keys(i),r,o;for(o=0;o<n.length;o++)r=n[o],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}function Yu(i,e){if(i==null)return{};var t=Xu(i,e),n,r;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(r=0;r<o.length;r++)n=o[r],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}function Ju(i){return Qu(i)||eh(i)||th(i)||ih()}function Qu(i){if(Array.isArray(i))return Fr(i)}function eh(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function th(i,e){if(i){if(typeof i=="string")return Fr(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Fr(i,e)}}function Fr(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function ih(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
+In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var nh="1.15.0";function $e(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var Me=$e(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),jt=$e(/Edge/i),Xo=$e(/firefox/i),Rt=$e(/safari/i)&&!$e(/chrome/i)&&!$e(/android/i),ss=$e(/iP(ad|od|hone)/i),as=$e(/chrome/i)&&$e(/android/i),ls={capture:!1,passive:!1};function P(i,e,t){i.addEventListener(e,t,!Me&&ls)}function B(i,e,t){i.removeEventListener(e,t,!Me&&ls)}function Ai(i,e){if(e){if(e[0]===">"&&(e=e.substring(1)),i)try{if(i.matches)return i.matches(e);if(i.msMatchesSelector)return i.msMatchesSelector(e);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(e)}catch{return!1}return!1}}function rh(i){return i.host&&i!==document&&i.host.nodeType?i.host:i.parentNode}function xe(i,e,t,n){if(i){t=t||document;do{if(e!=null&&(e[0]===">"?i.parentNode===t&&Ai(i,e):Ai(i,e))||n&&i===t)return i;if(i===t)break}while(i=rh(i))}return null}var Yo=/\s+/g;function X(i,e,t){if(i&&e)if(i.classList)i.classList[t?"add":"remove"](e);else{var n=(" "+i.className+" ").replace(Yo," ").replace(" "+e+" "," ");i.className=(n+(t?" "+e:"")).replace(Yo," ")}}function A(i,e,t){var n=i&&i.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(t=i.currentStyle),e===void 0?t:t[e];!(e in n)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),n[e]=t+(typeof t=="string"?"":"px")}}function Xe(i,e){var t="";if(typeof i=="string")t=i;else do{var n=A(i,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(i=i.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function cs(i,e,t){if(i){var n=i.getElementsByTagName(e),r=0,o=n.length;if(t)for(;r<o;r++)t(n[r],r);return n}return[]}function Se(){var i=document.scrollingElement;return i||document.documentElement}function j(i,e,t,n,r){if(!(!i.getBoundingClientRect&&i!==window)){var o,s,a,l,c,u,h;if(i!==window&&i.parentNode&&i!==Se()?(o=i.getBoundingClientRect(),s=o.top,a=o.left,l=o.bottom,c=o.right,u=o.height,h=o.width):(s=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||t)&&i!==window&&(r=r||i.parentNode,!Me))do if(r&&r.getBoundingClientRect&&(A(r,"transform")!=="none"||t&&A(r,"position")!=="static")){var d=r.getBoundingClientRect();s-=d.top+parseInt(A(r,"border-top-width")),a-=d.left+parseInt(A(r,"border-left-width")),l=s+o.height,c=a+o.width;break}while(r=r.parentNode);if(n&&i!==window){var p=Xe(r||i),f=p&&p.a,m=p&&p.d;p&&(s/=m,a/=f,h/=f,u/=m,l=s+u,c=a+h)}return{top:s,left:a,bottom:l,right:c,width:h,height:u}}}function Jo(i,e,t){for(var n=je(i,!0),r=j(i)[e];n;){var o=j(n)[t],s=void 0;if(t==="top"||t==="left"?s=r>=o:s=r<=o,!s)return n;if(n===Se())break;n=je(n,!1)}return!1}function pt(i,e,t,n){for(var r=0,o=0,s=i.children;o<s.length;){if(s[o].style.display!=="none"&&s[o]!==$.ghost&&(n||s[o]!==$.dragged)&&xe(s[o],t.draggable,i,!1)){if(r===e)return s[o];r++}o++}return null}function Rr(i,e){for(var t=i.lastElementChild;t&&(t===$.ghost||A(t,"display")==="none"||e&&!Ai(t,e));)t=t.previousElementSibling;return t||null}function Y(i,e){var t=0;if(!i||!i.parentNode)return-1;for(;i=i.previousElementSibling;)i.nodeName.toUpperCase()!=="TEMPLATE"&&i!==$.clone&&(!e||Ai(i,e))&&t++;return t}function Qo(i){var e=0,t=0,n=Se();if(i)do{var r=Xe(i),o=r.a,s=r.d;e+=i.scrollLeft*o,t+=i.scrollTop*s}while(i!==n&&(i=i.parentNode));return[e,t]}function oh(i,e){for(var t in i)if(i.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===i[t][n])return Number(t)}return-1}function je(i,e){if(!i||!i.getBoundingClientRect)return Se();var t=i,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=A(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Se();if(n||e)return t;n=!0}}while(t=t.parentNode);return Se()}function sh(i,e){if(i&&e)for(var t in e)e.hasOwnProperty(t)&&(i[t]=e[t]);return i}function _r(i,e){return Math.round(i.top)===Math.round(e.top)&&Math.round(i.left)===Math.round(e.left)&&Math.round(i.height)===Math.round(e.height)&&Math.round(i.width)===Math.round(e.width)}var Nt;function us(i,e){return function(){if(!Nt){var t=arguments,n=this;t.length===1?i.call(n,t[0]):i.apply(n,t),Nt=setTimeout(function(){Nt=void 0},e)}}}function ah(){clearTimeout(Nt),Nt=void 0}function hs(i,e,t){i.scrollLeft+=e,i.scrollTop+=t}function Nr(i){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(i).cloneNode(!0):t?t(i).clone(!0)[0]:i.cloneNode(!0)}function es(i,e){A(i,"position","absolute"),A(i,"top",e.top),A(i,"left",e.left),A(i,"width",e.width),A(i,"height",e.height)}function Er(i){A(i,"position",""),A(i,"top",""),A(i,"left",""),A(i,"width",""),A(i,"height","")}var ie="Sortable"+new Date().getTime();function lh(){var i=[],e;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(r){if(!(A(r,"display")==="none"||r===$.ghost)){i.push({target:r,rect:j(r)});var o=Ae({},i[i.length-1].rect);if(r.thisAnimationDuration){var s=Xe(r,!0);s&&(o.top-=s.f,o.left-=s.e)}r.fromRect=o}})}},addAnimationState:function(n){i.push(n)},removeAnimationState:function(n){i.splice(oh(i,{target:n}),1)},animateAll:function(n){var r=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var o=!1,s=0;i.forEach(function(a){var l=0,c=a.target,u=c.fromRect,h=j(c),d=c.prevFromRect,p=c.prevToRect,f=a.rect,m=Xe(c,!0);m&&(h.top-=m.f,h.left-=m.e),c.toRect=h,c.thisAnimationDuration&&_r(d,h)&&!_r(u,h)&&(f.top-h.top)/(f.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(l=uh(f,d,p,r.options)),_r(h,u)||(c.prevFromRect=u,c.prevToRect=h,l||(l=r.options.animation),r.animate(c,f,h,l)),l&&(o=!0,s=Math.max(s,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),o?e=setTimeout(function(){typeof n=="function"&&n()},s):typeof n=="function"&&n(),i=[]},animate:function(n,r,o,s){if(s){A(n,"transition",""),A(n,"transform","");var a=Xe(this.el),l=a&&a.a,c=a&&a.d,u=(r.left-o.left)/(l||1),h=(r.top-o.top)/(c||1);n.animatingX=!!u,n.animatingY=!!h,A(n,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=ch(n),A(n,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:"")),A(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){A(n,"transition",""),A(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},s)}}}}function ch(i){return i.offsetWidth}function uh(i,e,t,n){return Math.sqrt(Math.pow(e.top-i.top,2)+Math.pow(e.left-i.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var lt=[],Sr={initializeByDefault:!0},Vt={mount:function(e){for(var t in Sr)Sr.hasOwnProperty(t)&&!(t in e)&&(e[t]=Sr[t]);lt.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),lt.push(e)},pluginEvent:function(e,t,n){var r=this;this.eventCanceled=!1,n.cancel=function(){r.eventCanceled=!0};var o=e+"Global";lt.forEach(function(s){t[s.pluginName]&&(t[s.pluginName][o]&&t[s.pluginName][o](Ae({sortable:t},n)),t.options[s.pluginName]&&t[s.pluginName][e]&&t[s.pluginName][e](Ae({sortable:t},n)))})},initializePlugins:function(e,t,n,r){lt.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ke(n,c.defaults)}});for(var o in e.options)if(e.options.hasOwnProperty(o)){var s=this.modifyOption(e,o,e.options[o]);typeof s<"u"&&(e.options[o]=s)}},getEventProperties:function(e,t){var n={};return lt.forEach(function(r){typeof r.eventProperties=="function"&&ke(n,r.eventProperties.call(t[r.pluginName],e))}),n},modifyOption:function(e,t,n){var r;return lt.forEach(function(o){e[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[t]=="function"&&(r=o.optionListeners[t].call(e[o.pluginName],n))}),r}};function qt(i){var e=i.sortable,t=i.rootEl,n=i.name,r=i.targetEl,o=i.cloneEl,s=i.toEl,a=i.fromEl,l=i.oldIndex,c=i.newIndex,u=i.oldDraggableIndex,h=i.newDraggableIndex,d=i.originalEvent,p=i.putSortable,f=i.extraEventProperties;if(e=e||t&&t[ie],!!e){var m,y=e.options,v="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Me&&!jt?m=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(n,!0,!0)),m.to=s||t,m.from=a||t,m.item=r||t,m.clone=o,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=u,m.newDraggableIndex=h,m.originalEvent=d,m.pullMode=p?p.lastPutMode:void 0;var b=Ae(Ae({},f),Vt.getEventProperties(n,e));for(var k in b)m[k]=b[k];t&&t.dispatchEvent(m),y[v]&&y[v].call(e,m)}}var hh=["evt"],ae=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.evt,o=Yu(n,hh);Vt.pluginEvent.bind($)(e,t,Ae({dragEl:C,parentEl:G,ghostEl:F,rootEl:U,nextEl:Ke,lastDownEl:Ci,cloneEl:W,cloneHidden:Ue,dragStarted:Bt,putSortable:Q,activeSortable:$.active,originalEvent:r,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He,hideGhostForTarget:ms,unhideGhostForTarget:gs,cloneNowHidden:function(){Ue=!0},cloneNowShown:function(){Ue=!1},dispatchSortableEvent:function(a){oe({sortable:t,name:a,originalEvent:r})}},o))};function oe(i){qt(Ae({putSortable:Q,cloneEl:W,targetEl:C,rootEl:U,oldIndex:dt,oldDraggableIndex:zt,newIndex:fe,newDraggableIndex:He},i))}var C,G,F,U,Ke,Ci,W,Ue,dt,fe,zt,He,gi,Q,ht=!1,Di=!1,Ti=[],Ge,we,Ar,Dr,ts,is,Bt,ct,Ht,Ut=!1,bi=!1,_i,te,Tr=[],qr=!1,Li=[],$i=typeof document<"u",vi=ss,ns=jt||Me?"cssFloat":"float",dh=$i&&!as&&!ss&&"draggable"in document.createElement("div"),ds=function(){if($i){if(Me)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}}(),ps=function(e,t){var n=A(e),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),o=pt(e,0,t),s=pt(e,1,t),a=o&&A(o),l=s&&A(s),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+j(o).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+j(s).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&a.float&&a.float!=="none"){var h=a.float==="left"?"left":"right";return s&&(l.clear==="both"||l.clear===h)?"vertical":"horizontal"}return o&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=r&&n[ns]==="none"||s&&n[ns]==="none"&&c+u>r)?"vertical":"horizontal"},ph=function(e,t,n){var r=n?e.left:e.top,o=n?e.right:e.bottom,s=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,c=n?t.width:t.height;return r===a||o===l||r+s/2===a+c/2},fh=function(e,t){var n;return Ti.some(function(r){var o=r[ie].options.emptyInsertThreshold;if(!(!o||Rr(r))){var s=j(r),a=e>=s.left-o&&e<=s.right+o,l=t>=s.top-o&&t<=s.bottom+o;if(a&&l)return n=r}}),n},fs=function(e){function t(o,s){return function(a,l,c,u){var h=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(o==null&&(s||h))return!0;if(o==null||o===!1)return!1;if(s&&o==="clone")return o;if(typeof o=="function")return t(o(a,l,c,u),s)(a,l,c,u);var d=(s?a:l).options.group.name;return o===!0||typeof o=="string"&&o===d||o.join&&o.indexOf(d)>-1}}var n={},r=e.group;(!r||ki(r)!="object")&&(r={name:r}),n.name=r.name,n.checkPull=t(r.pull,!0),n.checkPut=t(r.put),n.revertClone=r.revertClone,e.group=n},ms=function(){!ds&&F&&A(F,"display","none")},gs=function(){!ds&&F&&A(F,"display","")};$i&&!as&&document.addEventListener("click",function(i){if(Di)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),Di=!1,!1},!0);var Ze=function(e){if(C){e=e.touches?e.touches[0]:e;var t=fh(e.clientX,e.clientY);if(t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[ie]._onDragOver(n)}}},mh=function(e){C&&C.parentNode[ie]._isOutsideThisEl(e.target)};function $(i,e){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=e=ke({},e),i[ie]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ps(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(s,a){s.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:$.supportPointer!==!1&&"PointerEvent"in window&&!Rt,emptyInsertThreshold:5};Vt.initializePlugins(this,i,t);for(var n in t)!(n in e)&&(e[n]=t[n]);fs(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:dh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?P(i,"pointerdown",this._onTapStart):(P(i,"mousedown",this._onTapStart),P(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(P(i,"dragover",this),P(i,"dragenter",this)),Ti.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ke(this,lh())}$.prototype={constructor:$,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ct=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,C):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,r=this.options,o=r.preventOnFilter,s=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=r.filter;if(Ch(n),!C&&!(/mousedown|pointerdown/.test(s)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Rt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=xe(l,r.draggable,n,!1),!(l&&l.animated)&&Ci!==l)){if(dt=Y(l),zt=Y(l,r.draggable),typeof u=="function"){if(u.call(this,e,l,this)){oe({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),ae("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=xe(c,h.trim(),n,!1),h)return oe({sortable:t,rootEl:h,name:"filter",targetEl:l,fromEl:n,toEl:n}),ae("filter",t,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}r.handle&&!xe(c,r.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var r=this,o=r.el,s=r.options,a=o.ownerDocument,l;if(n&&!C&&n.parentNode===o){var c=j(n);if(U=o,C=n,G=C.parentNode,Ke=C.nextSibling,Ci=n,gi=s.group,$.dragged=C,Ge={target:C,clientX:(t||e).clientX,clientY:(t||e).clientY},ts=Ge.clientX-c.left,is=Ge.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,C.style["will-change"]="all",l=function(){if(ae("delayEnded",r,{evt:e}),$.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Xo&&r.nativeDraggable&&(C.draggable=!0),r._triggerDragStart(e,t),oe({sortable:r,name:"choose",originalEvent:e}),X(C,s.chosenClass,!0)},s.ignore.split(",").forEach(function(u){cs(C,u.trim(),Lr)}),P(a,"dragover",Ze),P(a,"mousemove",Ze),P(a,"touchmove",Ze),P(a,"mouseup",r._onDrop),P(a,"touchend",r._onDrop),P(a,"touchcancel",r._onDrop),Xo&&this.nativeDraggable&&(this.options.touchStartThreshold=4,C.draggable=!0),ae("delayStart",this,{evt:e}),s.delay&&(!s.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(jt||Me))){if($.eventCanceled){this._onDrop();return}P(a,"mouseup",r._disableDelayedDrag),P(a,"touchend",r._disableDelayedDrag),P(a,"touchcancel",r._disableDelayedDrag),P(a,"mousemove",r._delayedDragTouchMoveHandler),P(a,"touchmove",r._delayedDragTouchMoveHandler),s.supportPointer&&P(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,s.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){C&&Lr(C),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._disableDelayedDrag),B(e,"touchend",this._disableDelayedDrag),B(e,"touchcancel",this._disableDelayedDrag),B(e,"mousemove",this._delayedDragTouchMoveHandler),B(e,"touchmove",this._delayedDragTouchMoveHandler),B(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?P(document,"pointermove",this._onTouchMove):t?P(document,"touchmove",this._onTouchMove):P(document,"mousemove",this._onTouchMove):(P(C,"dragend",this),P(U,"dragstart",this._onDragStart));try{document.selection?Ei(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ht=!1,U&&C){ae("dragStarted",this,{evt:t}),this.nativeDraggable&&P(document,"dragover",mh);var n=this.options;!e&&X(C,n.dragClass,!1),X(C,n.ghostClass,!0),$.active=this,e&&this._appendGhost(),oe({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(we){this._lastX=we.clientX,this._lastY=we.clientY,ms();for(var e=document.elementFromPoint(we.clientX,we.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(we.clientX,we.clientY),e!==t);)t=e;if(C.parentNode[ie]._isOutsideThisEl(e),t)do{if(t[ie]){var n=void 0;if(n=t[ie]._onDragOver({clientX:we.clientX,clientY:we.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);gs()}},_onTouchMove:function(e){if(Ge){var t=this.options,n=t.fallbackTolerance,r=t.fallbackOffset,o=e.touches?e.touches[0]:e,s=F&&Xe(F,!0),a=F&&s&&s.a,l=F&&s&&s.d,c=vi&&te&&Qo(te),u=(o.clientX-Ge.clientX+r.x)/(a||1)+(c?c[0]-Tr[0]:0)/(a||1),h=(o.clientY-Ge.clientY+r.y)/(l||1)+(c?c[1]-Tr[1]:0)/(l||1);if(!$.active&&!ht){if(n&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(F){s?(s.e+=u-(Ar||0),s.f+=h-(Dr||0)):s={a:1,b:0,c:0,d:1,e:u,f:h};var d="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");A(F,"webkitTransform",d),A(F,"mozTransform",d),A(F,"msTransform",d),A(F,"transform",d),Ar=u,Dr=h,we=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!F){var e=this.options.fallbackOnBody?document.body:U,t=j(C,!0,vi,!0,e),n=this.options;if(vi){for(te=e;A(te,"position")==="static"&&A(te,"transform")==="none"&&te!==document;)te=te.parentNode;te!==document.body&&te!==document.documentElement?(te===document&&(te=Se()),t.top+=te.scrollTop,t.left+=te.scrollLeft):te=Se(),Tr=Qo(te)}F=C.cloneNode(!0),X(F,n.ghostClass,!1),X(F,n.fallbackClass,!0),X(F,n.dragClass,!0),A(F,"transition",""),A(F,"transform",""),A(F,"box-sizing","border-box"),A(F,"margin",0),A(F,"top",t.top),A(F,"left",t.left),A(F,"width",t.width),A(F,"height",t.height),A(F,"opacity","0.8"),A(F,"position",vi?"absolute":"fixed"),A(F,"zIndex","100000"),A(F,"pointerEvents","none"),$.ghost=F,e.appendChild(F),A(F,"transform-origin",ts/parseInt(F.style.width)*100+"% "+is/parseInt(F.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,r=e.dataTransfer,o=n.options;if(ae("dragStart",this,{evt:e}),$.eventCanceled){this._onDrop();return}ae("setupClone",this),$.eventCanceled||(W=Nr(C),W.removeAttribute("id"),W.draggable=!1,W.style["will-change"]="",this._hideClone(),X(W,this.options.chosenClass,!1),$.clone=W),n.cloneId=Ei(function(){ae("clone",n),!$.eventCanceled&&(n.options.removeCloneOnHide||U.insertBefore(W,C),n._hideClone(),oe({sortable:n,name:"clone"}))}),!t&&X(C,o.dragClass,!0),t?(Di=!0,n._loopId=setInterval(n._emulateDragOver,50)):(B(document,"mouseup",n._onDrop),B(document,"touchend",n._onDrop),B(document,"touchcancel",n._onDrop),r&&(r.effectAllowed="move",o.setData&&o.setData.call(n,r,C)),P(document,"drop",n),A(C,"transform","translateZ(0)")),ht=!0,n._dragStartId=Ei(n._dragStarted.bind(n,t,e)),P(document,"selectstart",n),Bt=!0,Rt&&A(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,r,o,s,a=this.options,l=a.group,c=$.active,u=gi===l,h=a.sort,d=Q||c,p,f=this,m=!1;if(qr)return;function y(Re,wu){ae(Re,f,Ae({evt:e,isOwner:u,axis:p?"vertical":"horizontal",revert:s,dragRect:r,targetRect:o,canSort:h,fromSortable:d,target:n,completed:b,onMove:function(Po,yu){return wi(U,t,C,r,Po,j(Po),e,yu)},changed:k},wu))}function v(){y("dragOverAnimationCapture"),f.captureAnimationState(),f!==d&&d.captureAnimationState()}function b(Re){return y("dragOverCompleted",{insertion:Re}),Re&&(u?c._hideClone():c._showClone(f),f!==d&&(X(C,Q?Q.options.ghostClass:c.options.ghostClass,!1),X(C,a.ghostClass,!0)),Q!==f&&f!==$.active?Q=f:f===$.active&&Q&&(Q=null),d===f&&(f._ignoreWhileAnimating=n),f.animateAll(function(){y("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(n===C&&!C.animated||n===t&&!n.animated)&&(ct=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(C.parentNode[ie]._isOutsideThisEl(e.target),!Re&&Ze(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function k(){fe=Y(C),He=Y(C,a.draggable),oe({sortable:f,name:"change",toEl:t,newIndex:fe,newDraggableIndex:He,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=xe(n,a.draggable,t,!0),y("dragOver"),$.eventCanceled)return m;if(C.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||f._ignoreWhileAnimating===n)return b(!1);if(Di=!1,c&&!a.disabled&&(u?h||(s=G!==U):Q===this||(this.lastPutMode=gi.checkPull(this,c,C,e))&&l.checkPut(this,c,C,e))){if(p=this._getDirection(e,n)==="vertical",r=j(C),y("dragOverValid"),$.eventCanceled)return m;if(s)return G=U,v(),this._hideClone(),y("revert"),$.eventCanceled||(Ke?U.insertBefore(C,Ke):U.appendChild(C)),b(!0);var w=Rr(t,a.draggable);if(!w||wh(e,p,this)&&!w.animated){if(w===C)return b(!1);if(w&&t===e.target&&(n=w),n&&(o=j(n)),wi(U,t,C,r,n,o,e,!!n)!==!1)return v(),w&&w.nextSibling?t.insertBefore(C,w.nextSibling):t.appendChild(C),G=t,k(),b(!0)}else if(w&&vh(e,p,this)){var _=pt(t,0,a,!0);if(_===C)return b(!1);if(n=_,o=j(n),wi(U,t,C,r,n,o,e,!1)!==!1)return v(),t.insertBefore(C,_),G=t,k(),b(!0)}else if(n.parentNode===t){o=j(n);var x=0,S,D=C.parentNode!==t,q=!ph(C.animated&&C.toRect||r,n.animated&&n.toRect||o,p),L=p?"top":"left",I=Jo(n,"top","top")||Jo(C,"top","top"),H=I?I.scrollTop:void 0;ct!==n&&(S=o[L],Ut=!1,bi=!q&&a.invertSwap||D),x=yh(e,n,o,p,q?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,bi,ct===n);var N;if(x!==0){var ee=Y(C);do ee-=x,N=G.children[ee];while(N&&(A(N,"display")==="none"||N===F))}if(x===0||N===n)return b(!1);ct=n,Ht=x;var ge=n.nextElementSibling,V=!1;V=x===1;var Oe=wi(U,t,C,r,n,o,e,V);if(Oe!==!1)return(Oe===1||Oe===-1)&&(V=Oe===1),qr=!0,setTimeout(bh,30),v(),V&&!ge?t.appendChild(C):n.parentNode.insertBefore(C,V?ge:n),I&&hs(I,0,H-I.scrollTop),G=C.parentNode,S!==void 0&&!bi&&(_i=Math.abs(S-j(n)[L])),k(),b(!0)}if(t.contains(C))return b(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){B(document,"mousemove",this._onTouchMove),B(document,"touchmove",this._onTouchMove),B(document,"pointermove",this._onTouchMove),B(document,"dragover",Ze),B(document,"mousemove",Ze),B(document,"touchmove",Ze)},_offUpEvents:function(){var e=this.el.ownerDocument;B(e,"mouseup",this._onDrop),B(e,"touchend",this._onDrop),B(e,"pointerup",this._onDrop),B(e,"touchcancel",this._onDrop),B(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(fe=Y(C),He=Y(C,n.draggable),ae("drop",this,{evt:e}),G=C&&C.parentNode,fe=Y(C),He=Y(C,n.draggable),$.eventCanceled){this._nulling();return}ht=!1,bi=!1,Ut=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Br(this.cloneId),Br(this._dragStartId),this.nativeDraggable&&(B(document,"drop",this),B(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Rt&&A(document.body,"user-select",""),A(C,"transform",""),e&&(Bt&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),F&&F.parentNode&&F.parentNode.removeChild(F),(U===G||Q&&Q.lastPutMode!=="clone")&&W&&W.parentNode&&W.parentNode.removeChild(W),C&&(this.nativeDraggable&&B(C,"dragend",this),Lr(C),C.style["will-change"]="",Bt&&!ht&&X(C,Q?Q.options.ghostClass:this.options.ghostClass,!1),X(C,this.options.chosenClass,!1),oe({sortable:this,name:"unchoose",toEl:G,newIndex:null,newDraggableIndex:null,originalEvent:e}),U!==G?(fe>=0&&(oe({rootEl:G,name:"add",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"remove",toEl:G,originalEvent:e}),oe({rootEl:G,name:"sort",toEl:G,fromEl:U,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),Q&&Q.save()):fe!==dt&&fe>=0&&(oe({sortable:this,name:"update",toEl:G,originalEvent:e}),oe({sortable:this,name:"sort",toEl:G,originalEvent:e})),$.active&&((fe==null||fe===-1)&&(fe=dt,He=zt),oe({sortable:this,name:"end",toEl:G,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ae("nulling",this),U=C=G=F=Ke=W=Ci=Ue=Ge=we=Bt=fe=He=dt=zt=ct=Ht=Q=gi=$.dragged=$.ghost=$.clone=$.active=null,Li.forEach(function(e){e.checked=!0}),Li.length=Ar=Dr=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":C&&(this._onDragOver(e),gh(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,r=0,o=n.length,s=this.options;r<o;r++)t=n[r],xe(t,s.draggable,this.el,!1)&&e.push(t.getAttribute(s.dataIdAttr)||kh(t));return e},sort:function(e,t){var n={},r=this.el;this.toArray().forEach(function(o,s){var a=r.children[s];xe(a,this.options.draggable,r,!1)&&(n[o]=a)},this),t&&this.captureAnimationState(),e.forEach(function(o){n[o]&&(r.removeChild(n[o]),r.appendChild(n[o]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return xe(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var r=Vt.modifyOption(this,e,t);typeof r<"u"?n[e]=r:n[e]=t,e==="group"&&fs(n)},destroy:function(){ae("destroy",this);var e=this.el;e[ie]=null,B(e,"mousedown",this._onTapStart),B(e,"touchstart",this._onTapStart),B(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(B(e,"dragover",this),B(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ti.splice(Ti.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ue){if(ae("hideClone",this),$.eventCanceled)return;A(W,"display","none"),this.options.removeCloneOnHide&&W.parentNode&&W.parentNode.removeChild(W),Ue=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ue){if(ae("showClone",this),$.eventCanceled)return;C.parentNode==U&&!this.options.group.revertClone?U.insertBefore(W,C):Ke?U.insertBefore(W,Ke):U.appendChild(W),this.options.group.revertClone&&this.animate(C,W),A(W,"display",""),Ue=!1}}};function gh(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function wi(i,e,t,n,r,o,s,a){var l,c=i[ie],u=c.options.onMove,h;return window.CustomEvent&&!Me&&!jt?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=i,l.dragged=t,l.draggedRect=n,l.related=r||e,l.relatedRect=o||j(e),l.willInsertAfter=a,l.originalEvent=s,i.dispatchEvent(l),u&&(h=u.call(c,l,s)),h}function Lr(i){i.draggable=!1}function bh(){qr=!1}function vh(i,e,t){var n=j(pt(t.el,0,t.options,!0)),r=10;return e?i.clientX<n.left-r||i.clientY<n.top&&i.clientX<n.right:i.clientY<n.top-r||i.clientY<n.bottom&&i.clientX<n.left}function wh(i,e,t){var n=j(Rr(t.el,t.options.draggable)),r=10;return e?i.clientX>n.right+r||i.clientX<=n.right&&i.clientY>n.bottom&&i.clientX>=n.left:i.clientX>n.right&&i.clientY>n.top||i.clientX<=n.right&&i.clientY>n.bottom+r}function yh(i,e,t,n,r,o,s,a){var l=n?i.clientY:i.clientX,c=n?t.height:t.width,u=n?t.top:t.left,h=n?t.bottom:t.right,d=!1;if(!s){if(a&&_i<c*r){if(!Ut&&(Ht===1?l>u+c*o/2:l<h-c*o/2)&&(Ut=!0),Ut)d=!0;else if(Ht===1?l<u+_i:l>h-_i)return-Ht}else if(l>u+c*(1-r)/2&&l<h-c*(1-r)/2)return xh(e)}return d=d||s,d&&(l<u+c*o/2||l>h-c*o/2)?l>u+c/2?1:-1:0}function xh(i){return Y(C)<Y(i)?1:-1}function kh(i){for(var e=i.tagName+i.className+i.src+i.href+i.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function Ch(i){Li.length=0;for(var e=i.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&Li.push(n)}}function Ei(i){return setTimeout(i,0)}function Br(i){return clearTimeout(i)}$i&&P(document,"touchmove",function(i){($.active||ht)&&i.cancelable&&i.preventDefault()});$.utils={on:P,off:B,css:A,find:cs,is:function(e,t){return!!xe(e,t,e,!1)},extend:sh,throttle:us,closest:xe,toggleClass:X,clone:Nr,index:Y,nextTick:Ei,cancelNextTick:Br,detectDirection:ps,getChild:pt};$.get=function(i){return i[ie]};$.mount=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&($.utils=Ae(Ae({},$.utils),n.utils)),Vt.mount(n)})};$.create=function(i,e){return new $(i,e)};$.version=nh;var K=[],Pt,Pr,Or=!1,Ir,$r,Ii,Ot;function _h(){function i(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return i.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?P(document,"dragover",this._handleAutoScroll):this.options.supportPointer?P(document,"pointermove",this._handleFallbackAutoScroll):n.touches?P(document,"touchmove",this._handleFallbackAutoScroll):P(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?B(document,"dragover",this._handleAutoScroll):(B(document,"pointermove",this._handleFallbackAutoScroll),B(document,"touchmove",this._handleFallbackAutoScroll),B(document,"mousemove",this._handleFallbackAutoScroll)),rs(),Si(),ah()},nulling:function(){Ii=Pr=Pt=Or=Ot=Ir=$r=null,K.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var r=this,o=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(o,s);if(Ii=t,n||this.options.forceAutoScrollFallback||jt||Me||Rt){Mr(t,this.options,a,n);var l=je(a,!0);Or&&(!Ot||o!==Ir||s!==$r)&&(Ot&&rs(),Ot=setInterval(function(){var c=je(document.elementFromPoint(o,s),!0);c!==l&&(l=c,Si()),Mr(t,r.options,c,n)},10),Ir=o,$r=s)}else{if(!this.options.bubbleScroll||je(a,!0)===Se()){Si();return}Mr(t,this.options,je(a,!1),!1)}}},ke(i,{pluginName:"scroll",initializeByDefault:!0})}function Si(){K.forEach(function(i){clearInterval(i.pid)}),K=[]}function rs(){clearInterval(Ot)}var Mr=us(function(i,e,t,n){if(e.scroll){var r=(i.touches?i.touches[0]:i).clientX,o=(i.touches?i.touches[0]:i).clientY,s=e.scrollSensitivity,a=e.scrollSpeed,l=Se(),c=!1,u;Pr!==t&&(Pr=t,Si(),Pt=e.scroll,u=e.scrollFn,Pt===!0&&(Pt=je(t,!0)));var h=0,d=Pt;do{var p=d,f=j(p),m=f.top,y=f.bottom,v=f.left,b=f.right,k=f.width,w=f.height,_=void 0,x=void 0,S=p.scrollWidth,D=p.scrollHeight,q=A(p),L=p.scrollLeft,I=p.scrollTop;p===l?(_=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"||q.overflowX==="visible"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"||q.overflowY==="visible")):(_=k<S&&(q.overflowX==="auto"||q.overflowX==="scroll"),x=w<D&&(q.overflowY==="auto"||q.overflowY==="scroll"));var H=_&&(Math.abs(b-r)<=s&&L+k<S)-(Math.abs(v-r)<=s&&!!L),N=x&&(Math.abs(y-o)<=s&&I+w<D)-(Math.abs(m-o)<=s&&!!I);if(!K[h])for(var ee=0;ee<=h;ee++)K[ee]||(K[ee]={});(K[h].vx!=H||K[h].vy!=N||K[h].el!==p)&&(K[h].el=p,K[h].vx=H,K[h].vy=N,clearInterval(K[h].pid),(H!=0||N!=0)&&(c=!0,K[h].pid=setInterval(function(){n&&this.layer===0&&$.active._onTouchMove(Ii);var ge=K[this.layer].vy?K[this.layer].vy*a:0,V=K[this.layer].vx?K[this.layer].vx*a:0;typeof u=="function"&&u.call($.dragged.parentNode[ie],V,ge,i,Ii,K[this.layer].el)!=="continue"||hs(K[this.layer].el,V,ge)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&d!==l&&(d=je(d,!1)));Or=c}},30),bs=function(e){var t=e.originalEvent,n=e.putSortable,r=e.dragEl,o=e.activeSortable,s=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=n||o;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,h=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(h)&&(s("spill"),this.onSpill({dragEl:r,putSortable:n}))}};function zr(){}zr.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var r=pt(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:bs};ke(zr,{pluginName:"revertOnSpill"});function Hr(){}Hr.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,r=n||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:bs};ke(Hr,{pluginName:"removeOnSpill"});var M=[],pe=[],$t,ye,Mt=!1,le=!1,ut=!1,z,Ft,yi;function vs(){function i(e){for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this));e.options.avoidImplicitDeselect||(e.options.supportPointer?P(document,"pointerup",this._deselectMultiDrag):(P(document,"mouseup",this._deselectMultiDrag),P(document,"touchend",this._deselectMultiDrag))),P(document,"keydown",this._checkKeyDown),P(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(r,o){var s="";M.length&&ye===e?M.forEach(function(a,l){s+=(l?", ":"")+a.textContent}):s=o.textContent,r.setData("Text",s)}}}return i.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var n=t.dragEl;z=n},delayEnded:function(){this.isMultiDrag=~M.indexOf(z)},setupClone:function(t){var n=t.sortable,r=t.cancel;if(this.isMultiDrag){for(var o=0;o<M.length;o++)pe.push(Nr(M[o])),pe[o].sortableIndex=M[o].sortableIndex,pe[o].draggable=!1,pe[o].style["will-change"]="",X(pe[o],this.options.selectedClass,!1),M[o]===z&&X(pe[o],this.options.chosenClass,!1);n._hideClone(),r()}},clone:function(t){var n=t.sortable,r=t.rootEl,o=t.dispatchSortableEvent,s=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||M.length&&ye===n&&(os(!0,r),o("clone"),s()))},showClone:function(t){var n=t.cloneNowShown,r=t.rootEl,o=t.cancel;this.isMultiDrag&&(os(!1,r),pe.forEach(function(s){A(s,"display","")}),n(),yi=!1,o())},hideClone:function(t){var n=this,r=t.sortable,o=t.cloneNowHidden,s=t.cancel;this.isMultiDrag&&(pe.forEach(function(a){A(a,"display","none"),n.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),o(),yi=!0,s())},dragStartGlobal:function(t){var n=t.sortable;!this.isMultiDrag&&ye&&ye.multiDrag._deselectMultiDrag(),M.forEach(function(r){r.sortableIndex=Y(r)}),M=M.sort(function(r,o){return r.sortableIndex-o.sortableIndex}),ut=!0},dragStarted:function(t){var n=this,r=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(r.captureAnimationState(),this.options.animation)){M.forEach(function(s){s!==z&&A(s,"position","absolute")});var o=j(z,!1,!0,!0);M.forEach(function(s){s!==z&&es(s,o)}),le=!0,Mt=!0}r.animateAll(function(){le=!1,Mt=!1,n.options.animation&&M.forEach(function(s){Er(s)}),n.options.sort&&xi()})}},dragOver:function(t){var n=t.target,r=t.completed,o=t.cancel;le&&~M.indexOf(n)&&(r(!1),o())},revert:function(t){var n=t.fromSortable,r=t.rootEl,o=t.sortable,s=t.dragRect;M.length>1&&(M.forEach(function(a){o.addAnimationState({target:a,rect:le?j(a):s}),Er(a),a.fromRect=s,n.removeAnimationState(a)}),le=!1,Eh(!this.options.removeCloneOnHide,r))},dragOverCompleted:function(t){var n=t.sortable,r=t.isOwner,o=t.insertion,s=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(o){if(r&&s._hideClone(),Mt=!1,c.animation&&M.length>1&&(le||!r&&!s.options.sort&&!l)){var u=j(z,!1,!0,!0);M.forEach(function(d){d!==z&&(es(d,u),a.appendChild(d))}),le=!0}if(!r)if(le||xi(),M.length>1){var h=yi;s._showClone(n),s.options.animation&&!yi&&h&&pe.forEach(function(d){s.addAnimationState({target:d,rect:Ft}),d.fromRect=Ft,d.thisAnimationDuration=null})}else s._showClone(n)}},dragOverAnimationCapture:function(t){var n=t.dragRect,r=t.isOwner,o=t.activeSortable;if(M.forEach(function(a){a.thisAnimationDuration=null}),o.options.animation&&!r&&o.multiDrag.isMultiDrag){Ft=ke({},n);var s=Xe(z,!0);Ft.top-=s.f,Ft.left-=s.e}},dragOverAnimationComplete:function(){le&&(le=!1,xi())},drop:function(t){var n=t.originalEvent,r=t.rootEl,o=t.parentEl,s=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(n){var h=this.options,d=o.children;if(!ut)if(h.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),X(z,h.selectedClass,!~M.indexOf(z)),~M.indexOf(z))M.splice(M.indexOf(z),1),$t=null,qt({sortable:s,rootEl:r,name:"deselect",targetEl:z,originalEvent:n});else{if(M.push(z),qt({sortable:s,rootEl:r,name:"select",targetEl:z,originalEvent:n}),n.shiftKey&&$t&&s.el.contains($t)){var p=Y($t),f=Y(z);if(~p&&~f&&p!==f){var m,y;for(f>p?(y=p,m=f):(y=f,m=p+1);y<m;y++)~M.indexOf(d[y])||(X(d[y],h.selectedClass,!0),M.push(d[y]),qt({sortable:s,rootEl:r,name:"select",targetEl:d[y],originalEvent:n}))}}else $t=z;ye=u}if(ut&&this.isMultiDrag){if(le=!1,(o[ie].options.sort||o!==r)&&M.length>1){var v=j(z),b=Y(z,":not(."+this.options.selectedClass+")");if(!Mt&&h.animation&&(z.thisAnimationDuration=null),u.captureAnimationState(),!Mt&&(h.animation&&(z.fromRect=v,M.forEach(function(w){if(w.thisAnimationDuration=null,w!==z){var _=le?j(w):v;w.fromRect=_,u.addAnimationState({target:w,rect:_})}})),xi(),M.forEach(function(w){d[b]?o.insertBefore(w,d[b]):o.appendChild(w),b++}),l===Y(z))){var k=!1;M.forEach(function(w){if(w.sortableIndex!==Y(w)){k=!0;return}}),k&&a("update")}M.forEach(function(w){Er(w)}),u.animateAll()}ye=u}(r===o||c&&c.lastPutMode!=="clone")&&pe.forEach(function(w){w.parentNode&&w.parentNode.removeChild(w)})}},nullingGlobal:function(){this.isMultiDrag=ut=!1,pe.length=0},destroyGlobal:function(){this._deselectMultiDrag(),B(document,"pointerup",this._deselectMultiDrag),B(document,"mouseup",this._deselectMultiDrag),B(document,"touchend",this._deselectMultiDrag),B(document,"keydown",this._checkKeyDown),B(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof ut<"u"&&ut)&&ye===this.sortable&&!(t&&xe(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;M.length;){var n=M[0];X(n,this.options.selectedClass,!1),M.shift(),qt({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:n,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=!1)}},ke(i,{pluginName:"multiDrag",utils:{select:function(t){var n=t.parentNode[ie];!n||!n.options.multiDrag||~M.indexOf(t)||(ye&&ye!==n&&(ye.multiDrag._deselectMultiDrag(),ye=n),X(t,n.options.selectedClass,!0),M.push(t))},deselect:function(t){var n=t.parentNode[ie],r=M.indexOf(t);!n||!n.options.multiDrag||!~r||(X(t,n.options.selectedClass,!1),M.splice(r,1))}},eventProperties:function(){var t=this,n=[],r=[];return M.forEach(function(o){n.push({multiDragElement:o,index:o.sortableIndex});var s;le&&o!==z?s=-1:le?s=Y(o,":not(."+t.options.selectedClass+")"):s=Y(o),r.push({multiDragElement:o,index:s})}),{items:Ju(M),clones:[].concat(pe),oldIndicies:n,newIndicies:r}},optionListeners:{multiDragKey:function(t){return t=t.toLowerCase(),t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}function Eh(i,e){M.forEach(function(t,n){var r=e.children[t.sortableIndex+(i?Number(n):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function os(i,e){pe.forEach(function(t,n){var r=e.children[t.sortableIndex+(i?Number(n):0)];r?e.insertBefore(t,r):e.appendChild(t)})}function xi(){M.forEach(function(i){i!==z&&i.parentNode&&i.parentNode.removeChild(i)})}$.mount(new _h);$.mount(Hr,zr);var Ye=$;var ws={name(i,e){let t=i.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created(i,e){let t=Number(i.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated(i,e){let t=Number(i.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst(i,e){let t=i.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast(i,e){let t=i.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},ys={up:{active(i,e){return!(i.previousElementSibling===null&&!e)},run(i,e){(i.previousElementSibling||e).insertAdjacentElement("beforebegin",i)}},down:{active(i,e){return!(i.nextElementSibling===null&&!e)},run(i,e){(i.nextElementSibling||e).insertAdjacentElement("afterend",i)}},next_book:{active(i,e,t){return t.nextElementSibling!==null},run(i,e,t){t.nextElementSibling.querySelector("ul").prepend(i)}},prev_book:{active(i,e,t){return t.previousElementSibling!==null},run(i,e,t){t.previousElementSibling.querySelector("ul").appendChild(i)}},next_chapter:{active(i,e){return i.dataset.type==="page"&&this.getNextChapter(i,e)},run(i,e){this.getNextChapter(i,e).querySelector("ul").prepend(i)},getNextChapter(i,e){let t=e||i,n=Array.from(t.parentElement.children),r=n.indexOf(t);return n.slice(r+1).find(o=>o.dataset.type==="chapter")}},prev_chapter:{active(i,e){return i.dataset.type==="page"&&this.getPrevChapter(i,e)},run(i,e){this.getPrevChapter(i,e).querySelector("ul").append(i)},getPrevChapter(i,e){let t=e||i,n=Array.from(t.parentElement.children),r=n.indexOf(t);return n.slice(0,r).reverse().find(o=>o.dataset.type==="chapter")}},book_end:{active(i,e){return e||e===null&&i.nextElementSibling},run(i,e,t){t.querySelector("ul").append(i)}},book_start:{active(i,e){return e||e===null&&i.previousElementSibling},run(i,e,t){t.querySelector("ul").prepend(i)}},before_chapter:{active(i,e){return e},run(i,e){e.insertAdjacentElement("beforebegin",i)}},after_chapter:{active(i,e){return e},run(i,e){e.insertAdjacentElement("afterend",i)}}},Mi=class extends g{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,Ye.mount(new vs);let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),this.setupSortPresets(),this.setupMoveActions(),window.$events.listen("entity-select-change",this.bookSelect.bind(this))}setupMoveActions(){this.container.addEventListener("click",e=>{if(e.target.matches("[data-move]")){let t=e.target.getAttribute("data-move"),n=e.target.closest("[data-id]");this.runSortAction(n,t)}}),this.updateMoveActionStateForAll()}setupSortPresets(){let e="",t=!1,n=["name","created","updated"];this.sortContainer.addEventListener("click",r=>{let o=r.target.closest(".sort-box-options [data-sort]");if(!o)return;r.preventDefault();let s=o.closest(".sort-box").querySelectorAll("ul"),a=o.getAttribute("data-sort");t=e===a?!t:!1;let l=ws[a];t&&n.includes(a)&&(l=function(u,h){return 0-ws[a](u,h)});for(let c of s)Array.from(c.children).filter(h=>h.matches("li")).sort(l).forEach(h=>{c.appendChild(h)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=`${e.link}/sort-item`;window.$http.get(n).then(r=>{let o=Ee(r.data);this.sortContainer.append(o),this.setupBookSortable(o),this.updateMoveActionStateForAll(),o.querySelector("summary").focus()})}setupBookSortable(e){let t=Array.from(e.querySelectorAll(".sort-list, .sortable-page-sublist")),n={name:"book",pull:["book","chapter"],put:["book","chapter"]},r={name:"chapter",pull:["book","chapter"],put(o,s,a){return a.getAttribute("data-type")==="page"}};for(let o of t)Ye.create(o,{group:o.classList.contains("sort-list")?n:r,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:()=>{this.ensureNoNestedChapters(),this.updateMapInput(),this.updateMoveActionStateForAll()},dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"Control",selectedClass:"sortable-selected"})}ensureNoNestedChapters(){let e=this.container.querySelectorAll('[data-type="chapter"] [data-type="chapter"]');for(let t of e)t.parentElement.closest('[data-type="chapter"]').insertAdjacentElement("afterend",t)}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.container.querySelectorAll(".sort-list");for(let n of t){let r=n.closest('[data-type="book"]').getAttribute("data-id"),o=Array.from(n.children).filter(s=>s.matches('[data-type="page"], [data-type="chapter"]'));for(let s=0;s<o.length;s++)this.addBookChildToMap(o[s],s,r,e)}return e}addBookChildToMap(e,t,n,r){let o=e.getAttribute("data-type"),s=!1,a=e.getAttribute("data-id");r.push({id:a,sort:t,parentChapter:s,type:o,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)r.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:n})}runSortAction(e,t){let n=e.parentElement.closest("li[data-id]"),r=e.parentElement.closest('[data-type="book"]');ys[t].run(e,n,r),this.updateMapInput(),this.updateMoveActionStateForAll(),e.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus()}updateMoveActionState(e){let t=e.parentElement.closest("li[data-id]"),n=e.parentElement.closest('[data-type="book"]');for(let[r,o]of Object.entries(ys)){let s=e.querySelector(`[data-move="${r}"]`);s.disabled=!o.active(e,t,n)}}updateMoveActionStateForAll(){let e=this.container.querySelectorAll('[data-type="chapter"],[data-type="page"]');for(let t of e)this.updateMoveActionState(t)}};var Fi=new WeakMap;function Wt(i,e,t=400,n=null){let r=Object.keys(e);for(let s of r)i.style[s]=e[s][0];let o=()=>{for(let s of r)i.style[s]=null;i.style.transition=null,i.removeEventListener("transitionend",o),Fi.delete(i),n&&n()};setTimeout(()=>{i.style.transition=`all ease-in-out ${t}ms`;for(let s of r)i.style[s]=e[s][1];i.addEventListener("transitionend",o),Fi.set(i,o)},15)}function Gt(i){Fi.has(i)&&Fi.get(i)()}function xs(i,e=400,t=null){Gt(i),i.style.display="block",Wt(i,{opacity:["0","1"]},e,()=>{t&&t()})}function ks(i,e=400,t=null){Gt(i),Wt(i,{opacity:["1","0"]},e,()=>{i.style.display="none",t&&t()})}function ft(i,e=400){Gt(i);let t=i.getBoundingClientRect().height,n=getComputedStyle(i),r=n.getPropertyValue("padding-top"),o=n.getPropertyValue("padding-bottom"),s={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[r,"0px"],paddingBottom:[o,"0px"]};Wt(i,s,e,()=>{i.style.display="none"})}function mt(i,e=400){Gt(i),i.style.display="block";let t=i.getBoundingClientRect().height,n=getComputedStyle(i),r=n.getPropertyValue("padding-top"),o=n.getPropertyValue("padding-bottom"),s={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",r],paddingBottom:["0px",o]};Wt(i,s,e)}function Cs(i,e=400){let t=i.getBoundingClientRect().height,n=getComputedStyle(i),r=n.getPropertyValue("padding-top"),o=n.getPropertyValue("padding-bottom");return()=>{Gt(i);let s=i.getBoundingClientRect().height,a=getComputedStyle(i),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${s}px`],overflow:["hidden","hidden"],paddingTop:[r,l],paddingBottom:[o,c]};Wt(i,u,e)}}var qi=class extends g{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),mt(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),ft(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Bi=class extends g{constructor(){super(...arguments);se(this,"editor",null);se(this,"saveCallback",null);se(this,"cancelCallback",null);se(this,"history",{});se(this,"historyKey","code_history")}setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",t=>{t.ctrlKey&&t.key==="Enter"&&this.save()}),O(this.languageButtons,t=>{let n=t.target.dataset.lang;this.languageInput.value=n,this.languageInputChange(n)}),st(this.languageInput,()=>this.save()),this.languageInput.addEventListener("input",()=>this.languageInputChange(this.languageInput.value)),O(this.saveButton,()=>this.save()),Z(this.historyList,"button","click",(t,n)=>{t.preventDefault();let r=n.dataset.time;this.editor&&this.editor.setContent(this.history[r])})}setupFavourites(){for(let t of this.languageButtons)this.setupFavouritesForButton(t);this.sortLanguageList()}setupFavouritesForButton(t){let n=t.dataset.lang,r=this.favourites.has(n);t.setAttribute("data-favourite",r?"true":"false"),Z(t.parentElement,".lang-option-favorite-toggle","click",()=>{r=!r,r?this.favourites.add(n):this.favourites.delete(n),t.setAttribute("data-favourite",r?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:n,active:r}),this.sortLanguageList(),r&&t.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let t=this.languageButtons.sort((n,r)=>{let o=n.dataset.favourite==="true",s=r.dataset.favourite==="true";return o&&!s?-1:s&&!o||n.dataset.lang>r.dataset.lang?1:-1}).map(n=>n.parentElement);for(let n of t)this.languageOptionsContainer.append(n)}save(){this.saveCallback&&this.saveCallback(this.editor.getContent(),this.languageInput.value),this.hide()}async open(t,n,r,o){this.languageInput.value=n,this.saveCallback=r,this.cancelCallback=o,await this.show(),this.languageInputChange(n),this.editor.setContent(t)}async show(){let t=await window.importVersioned("code");this.editor||(this.editor=t.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{this.editor.focus()},()=>{this.addHistory(),this.cancelCallback&&this.cancelCallback()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(t){this.editor.setMode(t,this.editor.getContent())}languageInputChange(t){this.updateEditorMode(t);let n=t.toLowerCase();for(let r of this.languageButtons){let o=r.dataset.lang.toLowerCase().trim(),s=n===o;r.classList.toggle("active",s),s&&r.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let t=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",t.length===0),this.historyList.innerHTML=t.map(n=>{let r=new Date(parseInt(n,10)).toLocaleTimeString();return`<li><button type="button" data-time="${n}" class="text-item">${r}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let t=this.editor.getContent();if(!t)return;let n=Object.keys(this.history).pop();if(this.history[n]===t)return;this.history[String(Date.now())]=t;let r=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,r)}};var Pi=class extends g{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var Oi=class extends g{async setup(){let{mode:e}=this.$opts;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Ri=class extends g{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),mt(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),ft(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var Ni=class extends g{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,O(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise(e=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var zi=class extends g{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var Hi=class extends g{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var Ui=class extends g{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,r=this.toggle.getBoundingClientRect().height,o=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,o?n=window.innerHeight-t.top-r/2:n=t.top),o?(this.menu.style.top="initial",this.menu.style.bottom=`${n}px`):(this.menu.style.top=`${n}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let s=this.menu.querySelector("input");s!==null&&s.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let e=new ze(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),O(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var ji=class extends g{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Ne(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let n of t){let r=!e||n.textContent.toLowerCase().includes(e);n.style.display=r?"flex":"none",n.classList.toggle("hidden",!r)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=Cs(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var Fe=class{constructor(e){this.data=e}hasItems(){return!!this.data&&!!this.data.types&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let{types:e}=this.data,t=[];for(let r of e)if(r.includes("image")){let o=this.data.getData(r);t.push(o.getAsFile())}let n=this.getFiles().filter(r=>r.type.includes("image"));return t.push(...n),t}getFiles(){let{files:e}=this.data;return[...e]}};async function Ur(i){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(i);return}let e=document.createElement("textarea");e.style="position: absolute; left: -1000px; top: -1000px;",e.value=i,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Vi=class extends g{setup(){this.container=this.$el,this.statusArea=this.$refs.statusArea,this.dropTarget=this.$refs.dropTarget,this.selectButtons=this.$manyRefs.selectButton||[],this.isActive=!0,this.url=this.$opts.url,this.method=(this.$opts.method||"post").toUpperCase(),this.successMessage=this.$opts.successMessage,this.errorMessage=this.$opts.errorMessage,this.uploadLimitMb=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.zoneText=this.$opts.zoneText,this.fileAcceptTypes=this.$opts.fileAccept,this.allowMultiple=this.$opts.allowMultiple==="true",this.setupListeners()}toggleActive(e){this.isActive=e}setupListeners(){O(this.selectButtons,this.manualSelectHandler.bind(this)),this.setupDropTargetHandlers()}setupDropTargetHandlers(){let e=0,t=()=>{this.hideOverlay(),e=0};this.dropTarget.addEventListener("dragenter",n=>{n.preventDefault(),e+=1,e===1&&this.isActive&&this.showOverlay()}),this.dropTarget.addEventListener("dragover",n=>{n.preventDefault()}),this.dropTarget.addEventListener("dragend",t),this.dropTarget.addEventListener("dragleave",()=>{e-=1,e===0&&t()}),this.dropTarget.addEventListener("drop",n=>{if(n.preventDefault(),t(),!this.isActive)return;let o=new Fe(n.dataTransfer).getFiles();for(let s of o)this.createUploadFromFile(s)})}manualSelectHandler(){let e=_e("input",{type:"file",style:"left: -400px; visibility: hidden; position: fixed;",accept:this.fileAcceptTypes,multiple:this.allowMultiple?"":null});this.container.append(e),e.click(),e.addEventListener("change",()=>{for(let t of e.files)this.createUploadFromFile(t);e.remove()})}showOverlay(){if(!this.dropTarget.querySelector(".dropzone-overlay")){let t=_e("div",{class:"dropzone-overlay"},[this.zoneText]);this.dropTarget.append(t)}}hideOverlay(){let e=this.dropTarget.querySelector(".dropzone-overlay");e&&e.remove()}createUploadFromFile(e){let{dom:t,status:n,progress:r,dismiss:o}=this.createDomForFile(e);this.statusArea.append(t);let s=this,a={file:e,dom:t,updateProgress(l){r.textContent=`${l}%`,r.style.width=`${l}%`},markError(l){n.setAttribute("data-status","error"),n.textContent=l,Tt(t),this.updateProgress(100)},markSuccess(l){n.setAttribute("data-status","success"),n.textContent=l,Tt(t),setTimeout(o,2400),s.$emit("upload-success",{name:e.name})}};return e.size>this.uploadLimitMb*1e6?(a.markError(this.uploadLimitMessage),a):(this.startXhrForUpload(a),a)}startXhrForUpload(e){let t=new FormData;t.append("file",e.file,e.file.name),this.method!=="POST"&&t.append("_method",this.method);let n=this,r=window.$http.createXMLHttpRequest("POST",this.url,{error(){e.markError(n.errorMessage)},readystatechange(){if(this.readyState===XMLHttpRequest.DONE&&this.status===200)e.markSuccess(n.successMessage);else if(this.readyState===XMLHttpRequest.DONE&&this.status>=400){let o=this.responseText,s=o.startsWith("{")?JSON.parse(o):{message:o},a=s?.message||s?.error||o;e.markError(a)}}});r.upload.addEventListener("progress",o=>{let s=Math.min(Math.ceil(o.loaded/o.total*100),100);e.updateProgress(s)}),r.setRequestHeader("Accept","application/json"),r.send(t)}createDomForFile(e){let t=_e("img",{src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"}),n=_e("div",{class:"dropzone-file-item-status"},[]),r=_e("div",{class:"dropzone-file-item-progress"}),o=_e("div",{class:"dropzone-file-item-image-wrap"},[t]),s=_e("div",{class:"dropzone-file-item"},[o,_e("div",{class:"dropzone-file-item-text-wrap"},[_e("div",{class:"dropzone-file-item-label"},[e.name]),at(),n]),r]);e.type.startsWith("image/")&&(t.src=URL.createObjectURL(e));let a=()=>{s.classList.add("dismiss"),s.addEventListener("animationend",()=>{s.remove()})};return s.addEventListener("click",a),{dom:s,progress:r,status:n,dismiss:a}}};var Wi=class extends g{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let n=t.dataset.tab;this.setActiveTab(n,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n of this.buttons)n.classList.remove("active"),n.dataset.tab===e&&n.classList.add("active");for(let n of this.contentElements)n.style.display="none",n.dataset.tabContent===e&&(n.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Gi=class extends g{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",e=>{let t=e.target.checked,n=document.querySelectorAll('input[name^="permissions[0]["]');for(let r of n)r.disabled=t,r.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",()=>{let e=this.roleSelect.value;e&&this.addRoleRow(e)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let n=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),r=Ee(n.data);this.roleContainer.append(r),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),{roleId:n}=e.dataset,{roleName:r}=e.dataset,o=document.createElement("option");o.value=n,o.textContent=r,this.roleSelect.append(o),t.remove()}};var Zi=class extends g{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),O(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0){this.clearSearch();return}this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var Ki=class extends g{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",()=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),Z(this.$el,"[data-entity-type]","keydown",t=>{if(t.ctrlKey&&t.code==="Enter"){let n=this.$el.closest("form");if(n){n.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),r=t[n+(e?1:-1)]||t[0];r&&r.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(n=>{this.resultsContainer.innerHTML=n.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),n=e.getAttribute("data-entity-type"),r=e.getAttribute("data-entity-id"),o=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=o?`${n}:${r}`:"";let s=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(r),name:a,link:s};o?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!o)&&(t&&this.confirmSelection(l),o&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Xi=class extends g{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e){this.callback=e,this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Yi=class extends g{setup(){this.container=this.$el,this.name=this.$opts.name,O(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Ji=class extends g{setup(){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(e){mt(e,200)}close(e){ft(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)(this.isOpen?this.close:this.open)(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var Qi=class extends g{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let e=Ne(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let{value:t}=this.input;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new ze(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let n=Ee(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(n),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var en=class extends g{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var tn=class extends g{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.uploadButton=this.$refs.uploadButton,this.uploadHint=this.$refs.uploadHint,this.formContainer=this.$refs.formContainer,this.formContainerPlaceholder=this.$refs.formContainerPlaceholder,this.dropzoneContainer=this.$refs.dropzoneContainer,this.loadMore=this.$refs.loadMore,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){O(this.filterTabs,n=>{this.resetAll(),this.filter=n.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",n=>{this.resetListView(),this.loadGallery(),this.cancelSearch.toggleAttribute("hidden",!this.searchInput.value),n.preventDefault()}),O(this.cancelSearch,()=>{this.resetListView(),this.resetSearchView(),this.loadGallery()}),Z(this.container,".load-more button","click",this.runLoadMore.bind(this)),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",n=>{n.target.src=window.baseUrl("loading_error.png")},!0),O(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),Z(this.formContainer,"#image-manager-delete","click",()=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",()=>{this.refreshGallery(),this.resetEditForm()}),this.container.addEventListener("dropzone-upload-success",this.refreshGallery.bind(this));let e=this.listContainer.parentElement,t=[];e.addEventListener("wheel",n=>{if(!(Math.ceil(e.scrollHeight-e.scrollTop)===e.clientHeight)||n.deltaY<1)return;let s=Date.now()-1e3;t.push(Date.now()),t=t.filter(a=>a>=s),t.length>5&&this.canLoadMore()&&this.runLoadMore()})}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show();let n=t!=="gallery";this.dropzoneContainer.classList.toggle("hidden",n),this.uploadButton.classList.toggle("hidden",n),this.uploadHint.classList.toggle("hidden",n),window.$components.firstOnElement(this.container,"dropzone").toggleActive(!n),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),Tt(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e;let n=t.querySelector(".load-more");n&&(n.remove(),this.loadMore.innerHTML=n.innerHTML),this.loadMore.toggleAttribute("hidden",!n),window.$components.init(t);for(let r of[...t.children])this.listContainer.appendChild(r)}setActiveFilterTab(e){for(let t of this.filterTabs){let n=t.dataset.filter===e;t.setAttribute("aria-selected",n?"true":"false")}}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value="",this.cancelSearch.toggleAttribute("hidden",!0)}resetEditForm(){this.formContainer.innerHTML="",this.formContainerPlaceholder.removeAttribute("hidden")}resetListView(){Dt(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,r=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(o=>{o.classList.remove("selected")}),r?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",r),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:r}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=r,this.formContainerPlaceholder.setAttribute("hidden",""),window.$components.init(this.formContainer)}runLoadMore(){Dt(this.loadMore),this.page+=1,this.loadGallery()}canLoadMore(){return this.loadMore.querySelector("button")&&!this.loadMore.hasAttribute("hidden")}};var nn=class extends g{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var rn=class extends g{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var qc=Ro(Tc()),Bc=Ro(Fc()),wn=class{constructor(){this.renderer=new qc.default({html:!0}),this.renderer.use(Bc.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Zp(i,e){return document.createElement(i,e)}function Kp(i,e,t){return document.createElementNS(i,e,t)}function Xp(){return et(document.createDocumentFragment())}function Yp(i){return document.createTextNode(i)}function Jp(i){return document.createComment(i)}function Qp(i,e,t){if(qe(i)){let n=i;for(;n&&qe(n);)n=et(n).parent;i=n??i}qe(e)&&(e=et(e,i)),t&&qe(t)&&(t=et(t).firstChildNode),i.insertBefore(e,t)}function ef(i,e){i.removeChild(e)}function tf(i,e){qe(e)&&(e=et(e,i)),i.appendChild(e)}function Pc(i){if(qe(i)){for(;i&&qe(i);)i=et(i).parent;return i??null}return i.parentNode}function nf(i){var e;if(qe(i)){let t=et(i),n=Pc(t);if(n&&t.lastChildNode){let r=Array.from(n.childNodes),o=r.indexOf(t.lastChildNode);return(e=r[o+1])!==null&&e!==void 0?e:null}return null}return i.nextSibling}function rf(i){return i.tagName}function of(i,e){i.textContent=e}function sf(i){return i.textContent}function af(i){return i.nodeType===1}function lf(i){return i.nodeType===3}function cf(i){return i.nodeType===8}function qe(i){return i.nodeType===11}function et(i,e){var t,n,r;let o=i;return(t=o.parent)!==null&&t!==void 0||(o.parent=e??null),(n=o.firstChildNode)!==null&&n!==void 0||(o.firstChildNode=i.firstChild),(r=o.lastChildNode)!==null&&r!==void 0||(o.lastChildNode=i.lastChild),o}var yn={createElement:Zp,createElementNS:Kp,createTextNode:Yp,createDocumentFragment:Xp,createComment:Jp,insertBefore:Qp,removeChild:ef,appendChild:tf,parentNode:Pc,nextSibling:nf,tagName:rf,setTextContent:of,getTextContent:sf,isElement:af,isText:lf,isComment:cf,isDocumentFragment:qe};function Be(i,e,t,n,r){let o=e===void 0?void 0:e.key;return{sel:i,data:e,children:t,text:n,elm:r,key:o}}var Oc=Array.isArray;function Rc(i){return typeof i=="string"||typeof i=="number"||i instanceof String||i instanceof Number}function xo(i){return i===void 0}function ce(i){return i!==void 0}var ko=Be("",{},[],void 0,void 0);function Jt(i,e){var t,n;let r=i.key===e.key,o=((t=i.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is),s=i.sel===e.sel,a=!i.sel&&i.sel===e.sel?typeof i.text==typeof e.text:!0;return s&&r&&o&&a}function hf(){throw new Error("The document fragment is not supported on this platform.")}function df(i,e){return i.isElement(e)}function pf(i,e){return i.isDocumentFragment(e)}function ff(i,e,t){var n;let r={};for(let o=e;o<=t;++o){let s=(n=i[o])===null||n===void 0?void 0:n.key;s!==void 0&&(r[s]=o)}return r}var mf=["create","update","remove","destroy","pre","post"];function Co(i,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=e!==void 0?e:yn;for(let f of mf)for(let m of i){let y=m[f];y!==void 0&&n[f].push(y)}function o(f){let m=f.id?"#"+f.id:"",y=f.getAttribute("class"),v=y?"."+y.split(" ").join("."):"";return Be(r.tagName(f).toLowerCase()+m+v,{},[],void 0,f)}function s(f){return Be(void 0,{},[],void 0,f)}function a(f,m){return function(){if(--m===0){let v=r.parentNode(f);r.removeChild(v,f)}}}function l(f,m){var y,v,b,k;let w,_=f.data;if(_!==void 0){let D=(y=_.hook)===null||y===void 0?void 0:y.init;ce(D)&&(D(f),_=f.data)}let x=f.children,S=f.sel;if(S==="!")xo(f.text)&&(f.text=""),f.elm=r.createComment(f.text);else if(S!==void 0){let D=S.indexOf("#"),q=S.indexOf(".",D),L=D>0?D:S.length,I=q>0?q:S.length,H=D!==-1||q!==-1?S.slice(0,Math.min(L,I)):S,N=f.elm=ce(_)&&ce(w=_.ns)?r.createElementNS(w,H,_):r.createElement(H,_);for(L<I&&N.setAttribute("id",S.slice(L+1,I)),q>0&&N.setAttribute("class",S.slice(I+1).replace(/\./g," ")),w=0;w<n.create.length;++w)n.create[w](ko,f);if(Oc(x))for(w=0;w<x.length;++w){let ge=x[w];ge!=null&&r.appendChild(N,l(ge,m))}else Rc(f.text)&&r.appendChild(N,r.createTextNode(f.text));let ee=f.data.hook;ce(ee)&&((v=ee.create)===null||v===void 0||v.call(ee,ko,f),ee.insert&&m.push(f))}else if(!((b=t?.experimental)===null||b===void 0)&&b.fragments&&f.children){for(f.elm=((k=r.createDocumentFragment)!==null&&k!==void 0?k:hf)(),w=0;w<n.create.length;++w)n.create[w](ko,f);for(w=0;w<f.children.length;++w){let D=f.children[w];D!=null&&r.appendChild(f.elm,l(D,m))}}else f.elm=r.createTextNode(f.text);return f.elm}function c(f,m,y,v,b,k){for(;v<=b;++v){let w=y[v];w!=null&&r.insertBefore(f,l(w,k),m)}}function u(f){var m,y;let v=f.data;if(v!==void 0){(y=(m=v?.hook)===null||m===void 0?void 0:m.destroy)===null||y===void 0||y.call(m,f);for(let b=0;b<n.destroy.length;++b)n.destroy[b](f);if(f.children!==void 0)for(let b=0;b<f.children.length;++b){let k=f.children[b];k!=null&&typeof k!="string"&&u(k)}}}function h(f,m,y,v){for(var b,k;y<=v;++y){let w,_,x=m[y];if(x!=null)if(ce(x.sel)){u(x),w=n.remove.length+1,_=a(x.elm,w);for(let D=0;D<n.remove.length;++D)n.remove[D](x,_);let S=(k=(b=x?.data)===null||b===void 0?void 0:b.hook)===null||k===void 0?void 0:k.remove;ce(S)?S(x,_):_()}else x.children?(u(x),h(f,x.children,0,x.children.length-1)):r.removeChild(f,x.elm)}}function d(f,m,y,v){let b=0,k=0,w=m.length-1,_=m[0],x=m[w],S=y.length-1,D=y[0],q=y[S],L,I,H,N;for(;b<=w&&k<=S;)_==null?_=m[++b]:x==null?x=m[--w]:D==null?D=y[++k]:q==null?q=y[--S]:Jt(_,D)?(p(_,D,v),_=m[++b],D=y[++k]):Jt(x,q)?(p(x,q,v),x=m[--w],q=y[--S]):Jt(_,q)?(p(_,q,v),r.insertBefore(f,_.elm,r.nextSibling(x.elm)),_=m[++b],q=y[--S]):Jt(x,D)?(p(x,D,v),r.insertBefore(f,x.elm,_.elm),x=m[--w],D=y[++k]):(L===void 0&&(L=ff(m,b,w)),I=L[D.key],xo(I)?r.insertBefore(f,l(D,v),_.elm):(H=m[I],H.sel!==D.sel?r.insertBefore(f,l(D,v),_.elm):(p(H,D,v),m[I]=void 0,r.insertBefore(f,H.elm,_.elm))),D=y[++k]);k<=S&&(N=y[S+1]==null?null:y[S+1].elm,c(f,N,y,k,S,v)),b<=w&&h(f,m,b,w)}function p(f,m,y){var v,b,k,w,_,x,S,D;let q=(v=m.data)===null||v===void 0?void 0:v.hook;(b=q?.prepatch)===null||b===void 0||b.call(q,f,m);let L=m.elm=f.elm;if(f===m)return;if(m.data!==void 0||ce(m.text)&&m.text!==f.text){(k=m.data)!==null&&k!==void 0||(m.data={}),(w=f.data)!==null&&w!==void 0||(f.data={});for(let N=0;N<n.update.length;++N)n.update[N](f,m);(S=(x=(_=m.data)===null||_===void 0?void 0:_.hook)===null||x===void 0?void 0:x.update)===null||S===void 0||S.call(x,f,m)}let I=f.children,H=m.children;xo(m.text)?ce(I)&&ce(H)?I!==H&&d(L,I,H,y):ce(H)?(ce(f.text)&&r.setTextContent(L,""),c(L,null,H,0,H.length-1,y)):ce(I)?h(L,I,0,I.length-1):ce(f.text)&&r.setTextContent(L,""):f.text!==m.text&&(ce(I)&&h(L,I,0,I.length-1),r.setTextContent(L,m.text)),(D=q?.postpatch)===null||D===void 0||D.call(q,f,m)}return function(m,y){let v,b,k,w=[];for(v=0;v<n.pre.length;++v)n.pre[v]();for(df(r,m)?m=o(m):pf(r,m)&&(m=s(m)),Jt(m,y)?p(m,y,w):(b=m.elm,k=r.parentNode(b),l(y,w),k!==null&&(r.insertBefore(k,y.elm,r.nextSibling(b)),h(k,[m],0,0))),v=0;v<w.length;++v)w[v].data.hook.insert(w[v]);for(v=0;v<n.post.length;++v)n.post[v]();return y}}function _o(i,e,t){if(i.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let r=e[n];if(typeof r=="string")continue;let o=r.data;o!==void 0&&_o(o,r.children,r.sel)}}function Qt(i,e){let t=e!==void 0?e:yn,n;if(t.isElement(i)){let r=i.id?"#"+i.id:"",o=i.getAttribute("class"),s=o?"."+o.split(" ").join("."):"",a=t.tagName(i).toLowerCase()+r+s,l={},c={},u={},h=[],d,p,f,m=i.attributes,y=i.childNodes;for(p=0,f=m.length;p<f;p++)d=m[p].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?c[d.slice(5)]=m[p].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=m[p].nodeValue);for(p=0,f=y.length;p<f;p++)h.push(Qt(y[p],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.dataset=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&_o(u,h,a),Be(a,u,h,void 0,i)}else return t.isText(i)?(n=t.getTextContent(i),Be(void 0,void 0,void 0,n,i)):t.isComment(i)?(n=t.getTextContent(i),Be("!",{},[],n,i)):Be("",{},[],void 0,i)}var gf="http://www.w3.org/1999/xlink",bf="http://www.w3.org/XML/1998/namespace";function Nc(i,e){let t,n=e.elm,r=i.data.attrs,o=e.data.attrs;if(!(!r&&!o)&&r!==o){r=r||{},o=o||{};for(t in o){let s=o[t];r[t]!==s&&(s===!0?n.setAttribute(t,""):s===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,s):t.charCodeAt(3)===58?n.setAttributeNS(bf,t,s):t.charCodeAt(5)===58?n.setAttributeNS(gf,t,s):n.setAttribute(t,s))}for(t in r)t in o||n.removeAttribute(t)}}var Eo={create:Nc,update:Nc};var xn;function vf(){return xn||(xn=Co([Eo]),xn)}function zc(i,e){let t=document.createElement("div");t.innerHTML=e,vf()(Qt(i),Qt(t))}var kn=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,n=e.target.closest("a");if(n!==null){e.preventDefault(),window.open(n.getAttribute("href"));return}let r=e.target.closest("[drawio-diagram]");if(r!==null&&t){this.editor.actions.editDrawing(r);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.doc.head.appendChild(n)}}patchWithHtml(e){let{body:t}=this.doc;if(t.children.length===0){let r=document.createElement("div");this.doc.body.append(r)}let n=t.children[0];zc(n,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};var Ie=null,Do,So,Ao;function To(i){Ie.contentWindow.postMessage(JSON.stringify(i),Do)}function wf(i){Ao&&Ao(i.data)}function yf(i){To({action:"export",format:"xmlpng",xml:i.xml,spin:"Updating drawing"})}function xf(){So&&So().then(i=>{To({action:"load",autosave:1,xml:i})})}function kf(){let i={};window.$events.emitPublic(Ie,"editor-drawio::configure",{config:i}),To({action:"configure",config:i})}function Hc(){window.removeEventListener("message",Uc),Ie&&document.body.removeChild(Ie)}function Uc(i){if(!i.data||i.data.length<1||i.origin!==Do)return;let e=JSON.parse(i.data);e.event==="init"?xf():e.event==="exit"?Hc():e.event==="save"?yf(e):e.event==="export"?wf(e):e.event==="configure"&&kf()}function ei(i,e,t){So=e,Ao=t,Ie=document.createElement("iframe"),Ie.setAttribute("frameborder","0"),window.addEventListener("message",Uc),Ie.setAttribute("src",i),Ie.setAttribute("class","fullscreen"),Ie.style.backgroundColor="#FFFFFF",document.body.appendChild(Ie),Do=new URL(i).origin}async function Lo(i,e){let t={image:i,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}function tt(){Hc()}async function Cn(i){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${i}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),tt(),e}}var ti,Io,xt,_n,kt,En,Pe,it,We,yt,ne,ue,ii,$o,ni,Mo,Ct,Sn,he,ve,Dn,Vc,An=class{constructor(e){re(this,ti);re(this,xt);re(this,kt);re(this,Pe);re(this,We);re(this,ne);re(this,ii);re(this,ni);re(this,Ct);re(this,he);re(this,Dn);this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=T(this,xt,_n).call(this);this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",""),window.$events.emit("editor-markdown-change",""),this.lastContent.html=t,this.lastContent.markdown=e,this.editor.display.patchWithHtml(t)}getContent(){return this.lastContent}showImageInsert(){window.$components.first("image-manager").show(t=>{let n=t.thumbs.display||t.url,o=`[](${t.url})`;T(this,Pe,it).call(this,o,o.length)},"gallery")}insertImage(){let e=``;T(this,Pe,it).call(this,e,e.length-1)}insertLink(){let e=T(this,We,yt).call(this),t=`[${e}]()`,n=e===""?-3:-1;T(this,Pe,it).call(this,t,t.length+n)}showImageManager(){let e=T(this,ne,ue).call(this);window.$components.first("image-manager").show(n=>{T(this,ti,Io).call(this,n,e)},"drawio")}showLinkSelector(){let e=T(this,ne,ue).call(this);window.$components.first("entity-selector-popup").show(n=>{let o=`[${T(this,We,yt).call(this,e)||n.name}](${n.link})`;T(this,Pe,it).call(this,o,o.length,e)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=T(this,ne,ue).call(this);ei(e,()=>Promise.resolve(""),n=>{let r={image:n,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",r).then(o=>{T(this,ti,Io).call(this,o.data,t),tt()}).catch(o=>{this.handleDrawingUploadError(o)})})}editDrawing(e){let{drawioUrl:t}=this.editor.config;if(!t)return;let n=T(this,ne,ue).call(this),r=e.getAttribute("drawio-diagram");ei(t,()=>Cn(r),o=>{let s={image:o,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",s).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=T(this,xt,_n).call(this).split(`