-`};zt.text=function(r,e){return fr(r[e].content)};zt.html_block=function(r,e){return r[e].content};zt.html_inline=function(r,e){return r[e].content};function Lr(){this.rules=pf({},zt)}Lr.prototype.renderAttrs=function(e){var t,n,i;if(!e.attrs)return"";for(i="",t=0,n=e.attrs.length;t<n;t++)i+=" "+fr(e.attrs[t][0])+'="'+fr(e.attrs[t][1])+'"';return i};Lr.prototype.renderToken=function(e,t,n){var i,s="",o=!1,a=e[t];return a.hidden?"":(a.block&&a.nesting!==-1&&t&&e[t-1].hidden&&(s+=`
-`),s+=(a.nesting===-1?"</":"<")+a.tag,s+=this.renderAttrs(a),a.nesting===0&&n.xhtmlOut&&(s+=" /"),a.block&&(o=!0,a.nesting===1&&t+1<e.length&&(i=e[t+1],(i.type==="inline"||i.hidden||i.nesting===-1&&i.tag===a.tag)&&(o=!1))),s+=o?`>
-`:">",s)};Lr.prototype.renderInline=function(r,e,t){for(var n,i="",s=this.rules,o=0,a=r.length;o<a;o++)n=r[o].type,typeof s[n]<"u"?i+=s[n](r,o,e,t,this):i+=this.renderToken(r,o,e);return i};Lr.prototype.renderInlineAsText=function(r,e,t){for(var n="",i=0,s=r.length;i<s;i++)r[i].type==="text"?n+=r[i].content:r[i].type==="image"?n+=this.renderInlineAsText(r[i].children,e,t):r[i].type==="softbreak"&&(n+=`
-`);return n};Lr.prototype.render=function(r,e,t){var n,i,s,o="",a=this.rules;for(n=0,i=r.length;n<i;n++)s=r[n].type,s==="inline"?o+=this.renderInline(r[n].children,e,t):typeof a[s]<"u"?o+=a[r[n].type](r,n,e,t,this):o+=this.renderToken(r,n,e,t);return o};pl.exports=Lr});var Si=ne((Oy,gl)=>{"use strict";function Mt(){this.__rules__=[],this.__cache__=null}Mt.prototype.__find__=function(r){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===r)return e;return-1};Mt.prototype.__compile__=function(){var r=this,e=[""];r.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n)})}),r.__cache__={},e.forEach(function(t){r.__cache__[t]=[],r.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||r.__cache__[t].push(n.fn))})})};Mt.prototype.at=function(r,e,t){var n=this.__find__(r),i=t||{};if(n===-1)throw new Error("Parser rule not found: "+r);this.__rules__[n].fn=e,this.__rules__[n].alt=i.alt||[],this.__cache__=null};Mt.prototype.before=function(r,e,t,n){var i=this.__find__(r),s=n||{};if(i===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(i,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};Mt.prototype.after=function(r,e,t,n){var i=this.__find__(r),s=n||{};if(i===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(i+1,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};Mt.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null};Mt.prototype.enable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var i=this.__find__(n);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[i].enabled=!0,t.push(n)},this),this.__cache__=null,t};Mt.prototype.enableOnly=function(r,e){Array.isArray(r)||(r=[r]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(r,e)};Mt.prototype.disable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var i=this.__find__(n);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[i].enabled=!1,t.push(n)},this),this.__cache__=null,t};Mt.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[]};gl.exports=Mt});var yl=ne((Py,vl)=>{"use strict";var gf=/\r\n?|\n/g,vf=/\0/g;vl.exports=function(e){var t;t=e.src.replace(gf,`
-`),t=t.replace(vf,"\uFFFD"),e.src=t}});var xl=ne((My,bl)=>{"use strict";bl.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 El=ne(($y,wl)=>{"use strict";wl.exports=function(e){var t=e.tokens,n,i,s;for(i=0,s=t.length;i<s;i++)n=t[i],n.type==="inline"&&e.md.inline.parse(n.content,e.md,e.env,n.children)}});var Sl=ne((_y,Cl)=>{"use strict";var yf=Be().arrayReplaceAt;function bf(r){return/^<a[>\s]/i.test(r)}function xf(r){return/^<\/a\s*>/i.test(r)}Cl.exports=function(e){var t,n,i,s,o,a,l,c,u,d,h,f,p,v,y,b,x=e.tokens,T;if(e.md.options.linkify){for(n=0,i=x.length;n<i;n++)if(!(x[n].type!=="inline"||!e.md.linkify.pretest(x[n].content)))for(s=x[n].children,p=0,t=s.length-1;t>=0;t--){if(a=s[t],a.type==="link_close"){for(t--;s[t].level!==a.level&&s[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(bf(a.content)&&p>0&&p--,xf(a.content)&&p++),!(p>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,T=e.md.linkify.match(u),l=[],f=a.level,h=0,T.length>0&&T[0].index===0&&t>0&&s[t-1].type==="text_special"&&(T=T.slice(1)),c=0;c<T.length;c++)v=T[c].url,y=e.md.normalizeLink(v),e.md.validateLink(y)&&(b=T[c].text,T[c].schema?T[c].schema==="mailto:"&&!/^mailto:/i.test(b)?b=e.md.normalizeLinkText("mailto:"+b).replace(/^mailto:/,""):b=e.md.normalizeLinkText(b):b=e.md.normalizeLinkText("http://"+b).replace(/^http:\/\//,""),d=T[c].index,d>h&&(o=new e.Token("text","",0),o.content=u.slice(h,d),o.level=f,l.push(o)),o=new e.Token("link_open","a",1),o.attrs=[["href",y]],o.level=f++,o.markup="linkify",o.info="auto",l.push(o),o=new e.Token("text","",0),o.content=b,o.level=f,l.push(o),o=new e.Token("link_close","a",-1),o.level=--f,o.markup="linkify",o.info="auto",l.push(o),h=T[c].lastIndex);h<u.length&&(o=new e.Token("text","",0),o.content=u.slice(h),o.level=f,l.push(o)),x[n].children=s=yf(s,t,l)}}}}});var Tl=ne((By,kl)=>{"use strict";var Al=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,wf=/\((c|tm|r)\)/i,Ef=/\((c|tm|r)\)/ig,Cf={c:"\xA9",r:"\xAE",tm:"\u2122"};function Sf(r,e){return Cf[e.toLowerCase()]}function Af(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&(t.content=t.content.replace(Ef,Sf)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function kf(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&Al.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++}kl.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(wf.test(e.tokens[t].content)&&Af(e.tokens[t].children),Al.test(e.tokens[t].content)&&kf(e.tokens[t].children))}});var Pl=ne((Ny,Ol)=>{"use strict";var Il=Be().isWhiteSpace,Dl=Be().isPunctChar,Ll=Be().isMdAsciiPunct,Tf=/['"]/,Fl=/['"]/g,Rl="\u2019";function Ai(r,e,t){return r.slice(0,e)+t+r.slice(e+1)}function If(r,e){var t,n,i,s,o,a,l,c,u,d,h,f,p,v,y,b,x,T,E,M,S;for(E=[],t=0;t<r.length;t++){for(n=r[t],l=r[t].level,x=E.length-1;x>=0&&!(E[x].level<=l);x--);if(E.length=x+1,n.type!=="text")continue;i=n.content,o=0,a=i.length;e:for(;o<a&&(Fl.lastIndex=o,s=Fl.exec(i),!!s);){if(y=b=!0,o=s.index+1,T=s[0]==="'",u=32,s.index-1>=0)u=i.charCodeAt(s.index-1);else for(x=t-1;x>=0&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x--)if(r[x].content){u=r[x].content.charCodeAt(r[x].content.length-1);break}if(d=32,o<a)d=i.charCodeAt(o);else for(x=t+1;x<r.length&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x++)if(r[x].content){d=r[x].content.charCodeAt(0);break}if(h=Ll(u)||Dl(String.fromCharCode(u)),f=Ll(d)||Dl(String.fromCharCode(d)),p=Il(u),v=Il(d),v?y=!1:f&&(p||h||(y=!1)),p?b=!1:h&&(v||f||(b=!1)),d===34&&s[0]==='"'&&u>=48&&u<=57&&(b=y=!1),y&&b&&(y=h,b=f),!y&&!b){T&&(n.content=Ai(n.content,s.index,Rl));continue}if(b){for(x=E.length-1;x>=0&&(c=E[x],!(E[x].level<l));x--)if(c.single===T&&E[x].level===l){c=E[x],T?(M=e.md.options.quotes[2],S=e.md.options.quotes[3]):(M=e.md.options.quotes[0],S=e.md.options.quotes[1]),n.content=Ai(n.content,s.index,S),r[c.token].content=Ai(r[c.token].content,c.pos,M),o+=S.length-1,c.token===t&&(o+=M.length-1),i=n.content,a=i.length,E.length=x;continue e}}y?E.push({token:t,pos:s.index,single:T,level:l}):b&&T&&(n.content=Ai(n.content,s.index,Rl))}}}Ol.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!Tf.test(e.tokens[t].content)||If(e.tokens[t].children,e)}});var $l=ne((Uy,Ml)=>{"use strict";Ml.exports=function(e){var t,n,i,s,o,a,l=e.tokens;for(t=0,n=l.length;t<n;t++)if(l[t].type==="inline"){for(i=l[t].children,o=i.length,s=0;s<o;s++)i[s].type==="text_special"&&(i[s].type="text");for(s=a=0;s<o;s++)i[s].type==="text"&&s+1<o&&i[s+1].type==="text"?i[s+1].content=i[s].content+i[s+1].content:(s!==a&&(i[a]=i[s]),a++);s!==a&&(i.length=a)}}});var ki=ne((zy,_l)=>{"use strict";function Fr(r,e,t){this.type=r,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}Fr.prototype.attrIndex=function(e){var t,n,i;if(!this.attrs)return-1;for(t=this.attrs,n=0,i=t.length;n<i;n++)if(t[n][0]===e)return n;return-1};Fr.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Fr.prototype.attrSet=function(e,t){var n=this.attrIndex(e),i=[e,t];n<0?this.attrPush(i):this.attrs[n]=i};Fr.prototype.attrGet=function(e){var t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n};Fr.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};_l.exports=Fr});var Ul=ne((jy,Nl)=>{"use strict";var Df=ki();function Bl(r,e,t){this.src=r,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Bl.prototype.Token=Df;Nl.exports=Bl});var jl=ne((Hy,zl)=>{"use strict";var Lf=Si(),ns=[["normalize",yl()],["block",xl()],["inline",El()],["linkify",Sl()],["replacements",Tl()],["smartquotes",Pl()],["text_join",$l()]];function is(){this.ruler=new Lf;for(var r=0;r<ns.length;r++)this.ruler.push(ns[r][0],ns[r][1])}is.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r)};is.prototype.State=Ul();zl.exports=is});var ql=ne((Vy,Vl)=>{"use strict";var os=Be().isSpace;function ss(r,e){var t=r.bMarks[e]+r.tShift[e],n=r.eMarks[e];return r.src.slice(t,n)}function Hl(r){var e=[],t=0,n=r.length,i,s=!1,o=0,a="";for(i=r.charCodeAt(t);t<n;)i===124&&(s?(a+=r.substring(o,t-1),o=t):(e.push(a+r.substring(o,t)),a="",o=t+1)),s=i===92,t++,i=r.charCodeAt(t);return e.push(a+r.substring(o)),e}Vl.exports=function(e,t,n,i){var s,o,a,l,c,u,d,h,f,p,v,y,b,x,T,E,M,S;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])||(M=e.src.charCodeAt(a++),M!==124&&M!==45&&M!==58)||a>=e.eMarks[u]||(S=e.src.charCodeAt(a++),S!==124&&S!==45&&S!==58&&!os(S))||M===45&&os(S))return!1;for(;a<e.eMarks[u];){if(s=e.src.charCodeAt(a),s!==124&&s!==45&&s!==58&&!os(s))return!1;a++}for(o=ss(e,t+1),d=o.split("|"),p=[],l=0;l<d.length;l++){if(v=d[l].trim(),!v){if(l===0||l===d.length-1)continue;return!1}if(!/^:?-+:?$/.test(v))return!1;v.charCodeAt(v.length-1)===58?p.push(v.charCodeAt(0)===58?"center":"right"):v.charCodeAt(0)===58?p.push("left"):p.push("")}if(o=ss(e,t).trim(),o.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(d=Hl(o),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),h=d.length,h===0||h!==p.length))return!1;if(i)return!0;for(x=e.parentType,e.parentType="table",E=e.md.block.ruler.getRules("blockquote"),f=e.push("table_open","table",1),f.map=y=[t,0],f=e.push("thead_open","thead",1),f.map=[t,t+1],f=e.push("tr_open","tr",1),f.map=[t,t+1],l=0;l<d.length;l++)f=e.push("th_open","th",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l].trim(),f.children=[],f=e.push("th_close","th",-1);for(f=e.push("tr_close","tr",-1),f=e.push("thead_close","thead",-1),u=t+2;u<n&&!(e.sCount[u]<e.blkIndent);u++){for(T=!1,l=0,c=E.length;l<c;l++)if(E[l](e,u,n,!0)){T=!0;break}if(T||(o=ss(e,u).trim(),!o)||e.sCount[u]-e.blkIndent>=4)break;for(d=Hl(o),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),u===t+2&&(f=e.push("tbody_open","tbody",1),f.map=b=[t+2,0]),f=e.push("tr_open","tr",1),f.map=[u,u+1],l=0;l<h;l++)f=e.push("td_open","td",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l]?d[l].trim():"",f.children=[],f=e.push("td_close","td",-1);f=e.push("tr_close","tr",-1)}return b&&(f=e.push("tbody_close","tbody",-1),b[1]=u),f=e.push("table_close","table",-1),y[1]=u,e.parentType=x,e.line=u,!0}});var Wl=ne((qy,Gl)=>{"use strict";Gl.exports=function(e,t,n){var i,s,o;if(e.sCount[t]-e.blkIndent<4)return!1;for(s=i=t+1;i<n;){if(e.isEmpty(i)){i++;continue}if(e.sCount[i]-e.blkIndent>=4){i++,s=i;continue}break}return e.line=s,o=e.push("code_block","code",0),o.content=e.getLines(t,s,4+e.blkIndent,!1)+`
-`,o.map=[t,e.line],!0}});var Kl=ne((Gy,Yl)=>{"use strict";Yl.exports=function(e,t,n,i){var s,o,a,l,c,u,d,h=!1,f=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||f+3>p||(s=e.src.charCodeAt(f),s!==126&&s!==96)||(c=f,f=e.skipChars(f,s),o=f-c,o<3)||(d=e.src.slice(c,f),a=e.src.slice(f,p),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(i)return!0;for(l=t;l++,!(l>=n||(f=c=e.bMarks[l]+e.tShift[l],p=e.eMarks[l],f<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(f)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(f=e.skipChars(f,s),!(f-c<o)&&(f=e.skipSpaces(f),!(f<p)))){h=!0;break}return o=e.sCount[t],e.line=l+(h?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,o,!0),u.markup=d,u.map=[t,e.line],!0}});var Ql=ne((Wy,Zl)=>{"use strict";var Xl=Be().isSpace;Zl.exports=function(e,t,n,i){var s,o,a,l,c,u,d,h,f,p,v,y,b,x,T,E,M,S,O,A,D=e.lineMax,I=e.bMarks[t]+e.tShift[t],P=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(I++)!==62)return!1;if(i)return!0;for(l=f=e.sCount[t]+1,e.src.charCodeAt(I)===32?(I++,l++,f++,s=!1,E=!0):e.src.charCodeAt(I)===9?(E=!0,(e.bsCount[t]+f)%4===3?(I++,l++,f++,s=!1):s=!0):E=!1,p=[e.bMarks[t]],e.bMarks[t]=I;I<P&&(o=e.src.charCodeAt(I),Xl(o));){o===9?f+=4-(f+e.bsCount[t]+(s?1:0))%4:f++;I++}for(v=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(E?1:0),u=I>=P,x=[e.sCount[t]],e.sCount[t]=f-l,T=[e.tShift[t]],e.tShift[t]=I-e.bMarks[t],S=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",h=t+1;h<n&&(A=e.sCount[h]<e.blkIndent,I=e.bMarks[h]+e.tShift[h],P=e.eMarks[h],!(I>=P));h++){if(e.src.charCodeAt(I++)===62&&!A){for(l=f=e.sCount[h]+1,e.src.charCodeAt(I)===32?(I++,l++,f++,s=!1,E=!0):e.src.charCodeAt(I)===9?(E=!0,(e.bsCount[h]+f)%4===3?(I++,l++,f++,s=!1):s=!0):E=!1,p.push(e.bMarks[h]),e.bMarks[h]=I;I<P&&(o=e.src.charCodeAt(I),Xl(o));){o===9?f+=4-(f+e.bsCount[h]+(s?1:0))%4:f++;I++}u=I>=P,v.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(E?1:0),x.push(e.sCount[h]),e.sCount[h]=f-l,T.push(e.tShift[h]),e.tShift[h]=I-e.bMarks[h];continue}if(u)break;for(M=!1,a=0,c=S.length;a<c;a++)if(S[a](e,h,n,!0)){M=!0;break}if(M){e.lineMax=h,e.blkIndent!==0&&(p.push(e.bMarks[h]),v.push(e.bsCount[h]),T.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}p.push(e.bMarks[h]),v.push(e.bsCount[h]),T.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]=-1}for(y=e.blkIndent,e.blkIndent=0,O=e.push("blockquote_open","blockquote",1),O.markup=">",O.map=d=[t,0],e.md.block.tokenize(e,t,h),O=e.push("blockquote_close","blockquote",-1),O.markup=">",e.lineMax=D,e.parentType=b,d[1]=e.line,a=0;a<T.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=T[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=v[a];return e.blkIndent=y,!0}});var ec=ne((Yy,Jl)=>{"use strict";var Ff=Be().isSpace;Jl.exports=function(e,t,n,i){var s,o,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c++),s!==42&&s!==45&&s!==95))return!1;for(o=1;c<u;){if(a=e.src.charCodeAt(c++),a!==s&&!Ff(a))return!1;a===s&&o++}return o<3?!1:(i||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(o+1).join(String.fromCharCode(s))),!0)}});var oc=ne((Ky,ic)=>{"use strict";var nc=Be().isSpace;function tc(r,e){var t,n,i,s;return n=r.bMarks[e]+r.tShift[e],i=r.eMarks[e],t=r.src.charCodeAt(n++),t!==42&&t!==45&&t!==43||n<i&&(s=r.src.charCodeAt(n),!nc(s))?-1:n}function rc(r,e){var t,n=r.bMarks[e]+r.tShift[e],i=n,s=r.eMarks[e];if(i+1>=s||(t=r.src.charCodeAt(i++),t<48||t>57))return-1;for(;;){if(i>=s)return-1;if(t=r.src.charCodeAt(i++),t>=48&&t<=57){if(i-n>=10)return-1;continue}if(t===41||t===46)break;return-1}return i<s&&(t=r.src.charCodeAt(i),!nc(t))?-1:i}function Rf(r,e){var t,n,i=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===i&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].hidden=!0,r.tokens[t].hidden=!0,t+=2)}ic.exports=function(e,t,n,i){var s,o,a,l,c,u,d,h,f,p,v,y,b,x,T,E,M,S,O,A,D,I,P,_,B,H,Q,Y,re=!1,ie=!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(i&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(re=!0),(P=rc(e,t))>=0){if(d=!0,B=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(B,P-1)),re&&b!==1)return!1}else if((P=tc(e,t))>=0)d=!1;else return!1;if(re&&e.skipSpaces(P)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(P-1),i)return!0;for(v=e.tokens.length,d?(Y=e.push("ordered_list_open","ol",1),b!==1&&(Y.attrs=[["start",b]])):Y=e.push("bullet_list_open","ul",1),Y.map=p=[t,0],Y.markup=String.fromCharCode(y),T=t,_=!1,Q=e.md.block.ruler.getRules("list"),S=e.parentType,e.parentType="list";T<n;){for(I=P,x=e.eMarks[T],u=E=e.sCount[T]+P-(e.bMarks[t]+e.tShift[t]);I<x;){if(s=e.src.charCodeAt(I),s===9)E+=4-(E+e.bsCount[T])%4;else if(s===32)E++;else break;I++}if(o=I,o>=x?c=1:c=E-u,c>4&&(c=1),l=u+c,Y=e.push("list_item_open","li",1),Y.markup=String.fromCharCode(y),Y.map=h=[t,0],d&&(Y.info=e.src.slice(B,P-1)),D=e.tight,A=e.tShift[t],O=e.sCount[t],M=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=o-e.bMarks[t],e.sCount[t]=E,o>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||_)&&(ie=!1),_=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=M,e.tShift[t]=A,e.sCount[t]=O,e.tight=D,Y=e.push("list_item_close","li",-1),Y.markup=String.fromCharCode(y),T=t=e.line,h[1]=T,o=e.bMarks[t],T>=n||e.sCount[T]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(H=!1,a=0,f=Q.length;a<f;a++)if(Q[a](e,T,n,!0)){H=!0;break}if(H)break;if(d){if(P=rc(e,T),P<0)break;B=e.bMarks[T]+e.tShift[T]}else if(P=tc(e,T),P<0)break;if(y!==e.src.charCodeAt(P-1))break}return d?Y=e.push("ordered_list_close","ol",-1):Y=e.push("bullet_list_close","ul",-1),Y.markup=String.fromCharCode(y),p[1]=T,e.line=T,e.parentType=S,ie&&Rf(e,v),!0}});var ac=ne((Xy,sc)=>{"use strict";var Of=Be().normalizeReference,Ti=Be().isSpace;sc.exports=function(e,t,n,i){var s,o,a,l,c,u,d,h,f,p,v,y,b,x,T,E,M=0,S=e.bMarks[t]+e.tShift[t],O=e.eMarks[t],A=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(S)!==91)return!1;for(;++S<O;)if(e.src.charCodeAt(S)===93&&e.src.charCodeAt(S-1)!==92){if(S+1===O||e.src.charCodeAt(S+1)!==58)return!1;break}for(l=e.lineMax,T=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";A<l&&!e.isEmpty(A);A++)if(!(e.sCount[A]-e.blkIndent>3)&&!(e.sCount[A]<0)){for(x=!1,u=0,d=T.length;u<d;u++)if(T[u](e,A,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,A,e.blkIndent,!1).trim(),O=b.length,S=1;S<O;S++){if(s=b.charCodeAt(S),s===91)return!1;if(s===93){f=S;break}else s===10?M++:s===92&&(S++,S<O&&b.charCodeAt(S)===10&&M++)}if(f<0||b.charCodeAt(f+1)!==58)return!1;for(S=f+2;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!Ti(s))break;if(v=e.md.helpers.parseLinkDestination(b,S,O),!v.ok||(c=e.md.normalizeLink(v.str),!e.md.validateLink(c)))return!1;for(S=v.pos,M+=v.lines,o=S,a=M,y=S;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!Ti(s))break;for(v=e.md.helpers.parseLinkTitle(b,S,O),S<O&&y!==S&&v.ok?(E=v.str,S=v.pos,M+=v.lines):(E="",S=o,M=a);S<O&&(s=b.charCodeAt(S),!!Ti(s));)S++;if(S<O&&b.charCodeAt(S)!==10&&E)for(E="",S=o,M=a;S<O&&(s=b.charCodeAt(S),!!Ti(s));)S++;return S<O&&b.charCodeAt(S)!==10||(h=Of(b.slice(1,f)),!h)?!1:(i||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[h]>"u"&&(e.env.references[h]={title:E,href:c}),e.parentType=p,e.line=t+M+1),!0)}});var cc=ne((Zy,lc)=>{"use strict";lc.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 ls=ne((Qy,as)=>{"use strict";var Pf="[a-zA-Z_:][a-zA-Z0-9:._-]*",Mf="[^\"'=<>`\\x00-\\x20]+",$f="'[^']*'",_f='"[^"]*"',Bf="(?:"+Mf+"|"+$f+"|"+_f+")",Nf="(?:\\s+"+Pf+"(?:\\s*=\\s*"+Bf+")?)",uc="<[A-Za-z][A-Za-z0-9\\-]*"+Nf+"*\\s*\\/?>",dc="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Uf="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",zf="<[?][\\s\\S]*?[?]>",jf="<![A-Z]+\\s+[^>]*>",Hf="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Vf=new RegExp("^(?:"+uc+"|"+dc+"|"+Uf+"|"+zf+"|"+jf+"|"+Hf+")"),qf=new RegExp("^(?:"+uc+"|"+dc+")");as.exports.HTML_TAG_RE=Vf;as.exports.HTML_OPEN_CLOSE_TAG_RE=qf});var fc=ne((Jy,hc)=>{"use strict";var Gf=cc(),Wf=ls().HTML_OPEN_CLOSE_TAG_RE,Rr=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Gf.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Wf.source+"\\s*$"),/^$/,!1]];hc.exports=function(e,t,n,i){var s,o,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),s=0;s<Rr.length&&!Rr[s][0].test(l);s++);if(s===Rr.length)return!1;if(i)return Rr[s][2];if(o=t+1,!Rr[s][1].test(l)){for(;o<n&&!(e.sCount[o]<e.blkIndent);o++)if(c=e.bMarks[o]+e.tShift[o],u=e.eMarks[o],l=e.src.slice(c,u),Rr[s][1].test(l)){l.length!==0&&o++;break}}return e.line=o,a=e.push("html_block","",0),a.map=[t,o],a.content=e.getLines(t,o,e.blkIndent,!0),!0}});var gc=ne((e0,mc)=>{"use strict";var pc=Be().isSpace;mc.exports=function(e,t,n,i){var s,o,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c),s!==35||c>=u))return!1;for(o=1,s=e.src.charCodeAt(++c);s===35&&c<u&&o<=6;)o++,s=e.src.charCodeAt(++c);return o>6||c<u&&!pc(s)?!1:(i||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&pc(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(o),1),l.markup="########".slice(0,o),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(o),-1),l.markup="########".slice(0,o)),!0)}});var yc=ne((t0,vc)=>{"use strict";vc.exports=function(e,t,n){var i,s,o,a,l,c,u,d,h,f=t+1,p,v=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";f<n&&!e.isEmpty(f);f++)if(!(e.sCount[f]-e.blkIndent>3)){if(e.sCount[f]>=e.blkIndent&&(c=e.bMarks[f]+e.tShift[f],u=e.eMarks[f],c<u&&(h=e.src.charCodeAt(c),(h===45||h===61)&&(c=e.skipChars(c,h),c=e.skipSpaces(c),c>=u)))){d=h===61?1:2;break}if(!(e.sCount[f]<0)){for(s=!1,o=0,a=v.length;o<a;o++)if(v[o](e,f,n,!0)){s=!0;break}if(s)break}}return d?(i=e.getLines(t,f,e.blkIndent,!1).trim(),e.line=f+1,l=e.push("heading_open","h"+String(d),1),l.markup=String.fromCharCode(h),l.map=[t,e.line],l=e.push("inline","",0),l.content=i,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(d),-1),l.markup=String.fromCharCode(h),e.parentType=p,!0):!1}});var xc=ne((r0,bc)=>{"use strict";bc.exports=function(e,t){var n,i,s,o,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),d=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<d&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(i=!1,s=0,o=u.length;s<o;s++)if(u[s](e,c,d,!0)){i=!0;break}if(i)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 Cc=ne((n0,Ec)=>{"use strict";var wc=ki(),Ii=Be().isSpace;function jt(r,e,t,n){var i,s,o,a,l,c,u,d;for(this.src=r,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="",s=this.src,d=!1,o=a=c=u=0,l=s.length;a<l;a++){if(i=s.charCodeAt(a),!d)if(Ii(i)){c++,i===9?u+=4-u%4:u++;continue}else d=!0;(i===10||a===l-1)&&(i!==10&&a++,this.bMarks.push(o),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),d=!1,c=0,u=0,o=a+1)}this.bMarks.push(s.length),this.eMarks.push(s.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}jt.prototype.push=function(r,e,t){var n=new wc(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};jt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};jt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};jt.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!Ii(t));e++);return e};jt.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!Ii(this.src.charCodeAt(--e)))return e+1;return e};jt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};jt.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};jt.prototype.getLines=function(e,t,n,i){var s,o,a,l,c,u,d,h=e;if(e>=t)return"";for(u=new Array(t-e),s=0;h<t;h++,s++){for(o=0,d=l=this.bMarks[h],h+1<t||i?c=this.eMarks[h]+1:c=this.eMarks[h];l<c&&o<n;){if(a=this.src.charCodeAt(l),Ii(a))a===9?o+=4-(o+this.bsCount[h])%4:o++;else if(l-d<this.tShift[h])o++;else break;l++}o>n?u[s]=new Array(o-n+1).join(" ")+this.src.slice(l,c):u[s]=this.src.slice(l,c)}return u.join("")};jt.prototype.Token=wc;Ec.exports=jt});var Ac=ne((i0,Sc)=>{"use strict";var Yf=Si(),Di=[["table",ql(),["paragraph","reference"]],["code",Wl()],["fence",Kl(),["paragraph","reference","blockquote","list"]],["blockquote",Ql(),["paragraph","reference","blockquote","list"]],["hr",ec(),["paragraph","reference","blockquote","list"]],["list",oc(),["paragraph","reference","blockquote"]],["reference",ac()],["html_block",fc(),["paragraph","reference","blockquote"]],["heading",gc(),["paragraph","reference","blockquote"]],["lheading",yc()],["paragraph",xc()]];function Li(){this.ruler=new Yf;for(var r=0;r<Di.length;r++)this.ruler.push(Di[r][0],Di[r][1],{alt:(Di[r][2]||[]).slice()})}Li.prototype.tokenize=function(r,e,t){for(var n,i,s=this.ruler.getRules(""),o=s.length,a=e,l=!1,c=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=c){r.line=t;break}for(i=0;i<o&&(n=s[i](r,a,t,!1),!n);i++);r.tight=!l,r.isEmpty(r.line-1)&&(l=!0),a=r.line,a<t&&r.isEmpty(a)&&(l=!0,a++,r.line=a)}};Li.prototype.parse=function(r,e,t,n){var i;r&&(i=new this.State(r,e,t,n),this.tokenize(i,i.line,i.lineMax))};Li.prototype.State=Cc();Sc.exports=Li});var Tc=ne((o0,kc)=>{"use strict";function Kf(r){switch(r){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}}kc.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!Kf(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var Dc=ne((s0,Ic)=>{"use strict";var Xf=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;Ic.exports=function(e,t){var n,i,s,o,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(n=e.pos,i=e.posMax,n+3>i)||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47||(s=e.pending.match(Xf),!s)||(o=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-o.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,-o.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-o.length,!0)}});var Fc=ne((a0,Lc)=>{"use strict";var Zf=Be().isSpace;Lc.exports=function(e,t){var n,i,s,o=e.pos;if(e.src.charCodeAt(o)!==10)return!1;if(n=e.pending.length-1,i=e.posMax,!t)if(n>=0&&e.pending.charCodeAt(n)===32)if(n>=1&&e.pending.charCodeAt(n-1)===32){for(s=n-1;s>=1&&e.pending.charCodeAt(s-1)===32;)s--;e.pending=e.pending.slice(0,s),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(o++;o<i&&Zf(e.src.charCodeAt(o));)o++;return e.pos=o,!0}});var Oc=ne((l0,Rc)=>{"use strict";var Qf=Be().isSpace,us=[];for(cs=0;cs<256;cs++)us.push(0);var cs;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){us[r.charCodeAt(0)]=1});Rc.exports=function(e,t){var n,i,s,o,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),!!Qf(n));)l++;return e.pos=l,!0}return o=e.src[l],n>=55296&&n<=56319&&l+1<c&&(i=e.src.charCodeAt(l+1),i>=56320&&i<=57343&&(o+=e.src[l+1],l++)),s="\\"+o,t||(a=e.push("text_special","",0),n<256&&us[n]!==0?a.content=o:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var Mc=ne((c0,Pc)=>{"use strict";Pc.exports=function(e,t){var n,i,s,o,a,l,c,u,d=e.pos,h=e.src.charCodeAt(d);if(h!==96)return!1;for(n=d,d++,i=e.posMax;d<i&&e.src.charCodeAt(d)===96;)d++;if(s=e.src.slice(n,d),c=s.length,e.backticksScanned&&(e.backticks[c]||0)<=n)return t||(e.pending+=s),e.pos+=c,!0;for(a=l=d;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<i&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(o=e.push("code_inline","code",0),o.markup=s,o.content=e.src.slice(d,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=c,!0}});var hs=ne((u0,ds)=>{"use strict";ds.exports.tokenize=function(e,t){var n,i,s,o,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(i=e.scanDelims(e.pos,!0),o=i.length,a=String.fromCharCode(c),o<2))return!1;for(o%2&&(s=e.push("text","",0),s.content=a,o--),n=0;n<o;n+=2)s=e.push("text","",0),s.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0};function $c(r,e){var t,n,i,s,o,a=[],l=e.length;for(t=0;t<l;t++)i=e[t],i.marker===126&&i.end!==-1&&(s=e[i.end],o=r.tokens[i.token],o.type="s_open",o.tag="s",o.nesting=1,o.markup="~~",o.content="",o=r.tokens[s.token],o.type="s_close",o.tag="s",o.nesting=-1,o.markup="~~",o.content="",r.tokens[s.token-1].type==="text"&&r.tokens[s.token-1].content==="~"&&a.push(s.token-1));for(;a.length;){for(t=a.pop(),n=t+1;n<r.tokens.length&&r.tokens[n].type==="s_close";)n++;n--,t!==n&&(o=r.tokens[n],r.tokens[n]=r.tokens[t],r.tokens[t]=o)}}ds.exports.postProcess=function(e){var t,n=e.tokens_meta,i=e.tokens_meta.length;for($c(e,e.delimiters),t=0;t<i;t++)n[t]&&n[t].delimiters&&$c(e,n[t].delimiters)}});var ps=ne((d0,fs)=>{"use strict";fs.exports.tokenize=function(e,t){var n,i,s,o=e.pos,a=e.src.charCodeAt(o);if(t||a!==95&&a!==42)return!1;for(i=e.scanDelims(e.pos,a===42),n=0;n<i.length;n++)s=e.push("text","",0),s.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0};function _c(r,e){var t,n,i,s,o,a,l=e.length;for(t=l-1;t>=0;t--)n=e[t],!(n.marker!==95&&n.marker!==42)&&n.end!==-1&&(i=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===i.token+1,o=String.fromCharCode(n.marker),s=r.tokens[n.token],s.type=a?"strong_open":"em_open",s.tag=a?"strong":"em",s.nesting=1,s.markup=a?o+o:o,s.content="",s=r.tokens[i.token],s.type=a?"strong_close":"em_close",s.tag=a?"strong":"em",s.nesting=-1,s.markup=a?o+o:o,s.content="",a&&(r.tokens[e[t-1].token].content="",r.tokens[e[n.end+1].token].content="",t--))}fs.exports.postProcess=function(e){var t,n=e.tokens_meta,i=e.tokens_meta.length;for(_c(e,e.delimiters),t=0;t<i;t++)n[t]&&n[t].delimiters&&_c(e,n[t].delimiters)}});var Nc=ne((h0,Bc)=>{"use strict";var Jf=Be().normalizeReference,ms=Be().isSpace;Bc.exports=function(e,t){var n,i,s,o,a,l,c,u,d,h="",f="",p=e.pos,v=e.posMax,y=e.pos,b=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,o=e.md.helpers.parseLinkLabel(e,e.pos,!0),o<0))return!1;if(l=o+1,l<v&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<v&&(i=e.src.charCodeAt(l),!(!ms(i)&&i!==10));l++);if(l>=v)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(h=e.md.normalizeLink(c.str),e.md.validateLink(h)?l=c.pos:h="",y=l;l<v&&(i=e.src.charCodeAt(l),!(!ms(i)&&i!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<v&&y!==l&&c.ok)for(f=c.str,l=c.pos;l<v&&(i=e.src.charCodeAt(l),!(!ms(i)&&i!==10));l++);}(l>=v||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<v&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(y,l++):l=o+1):l=o+1,s||(s=e.src.slice(a,o)),u=e.env.references[Jf(s)],!u)return e.pos=p,!1;h=u.href,f=u.title}return t||(e.pos=a,e.posMax=o,d=e.push("link_open","a",1),d.attrs=n=[["href",h]],f&&n.push(["title",f]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,d=e.push("link_close","a",-1)),e.pos=l,e.posMax=v,!0}});var zc=ne((f0,Uc)=>{"use strict";var ep=Be().normalizeReference,gs=Be().isSpace;Uc.exports=function(e,t){var n,i,s,o,a,l,c,u,d,h,f,p,v,y="",b=e.pos,x=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<x&&e.src.charCodeAt(c)===40){for(c++;c<x&&(i=e.src.charCodeAt(c),!(!gs(i)&&i!==10));c++);if(c>=x)return!1;for(v=c,d=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),d.ok&&(y=e.md.normalizeLink(d.str),e.md.validateLink(y)?c=d.pos:y=""),v=c;c<x&&(i=e.src.charCodeAt(c),!(!gs(i)&&i!==10));c++);if(d=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<x&&v!==c&&d.ok)for(h=d.str,c=d.pos;c<x&&(i=e.src.charCodeAt(c),!(!gs(i)&&i!==10));c++);else h="";if(c>=x||e.src.charCodeAt(c)!==41)return e.pos=b,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<x&&e.src.charCodeAt(c)===91?(v=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?o=e.src.slice(v,c++):c=a+1):c=a+1,o||(o=e.src.slice(l,a)),u=e.env.references[ep(o)],!u)return e.pos=b,!1;y=u.href,h=u.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),f=e.push("image","img",0),f.attrs=n=[["src",y],["alt",""]],f.children=p,f.content=s,h&&n.push(["title",h])),e.pos=c,e.posMax=x,!0}});var Hc=ne((p0,jc)=>{"use strict";var tp=/^([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])?)*)$/,rp=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;jc.exports=function(e,t){var n,i,s,o,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(o=e.src.charCodeAt(c),o===60))return!1;if(o===62)break}return n=e.src.slice(a+1,c),rp.test(n)?(i=e.md.normalizeLink(n),e.md.validateLink(i)?(t||(s=e.push("link_open","a",1),s.attrs=[["href",i]],s.markup="autolink",s.info="auto",s=e.push("text","",0),s.content=e.md.normalizeLinkText(n),s=e.push("link_close","a",-1),s.markup="autolink",s.info="auto"),e.pos+=n.length+2,!0):!1):tp.test(n)?(i=e.md.normalizeLink("mailto:"+n),e.md.validateLink(i)?(t||(s=e.push("link_open","a",1),s.attrs=[["href",i]],s.markup="autolink",s.info="auto",s=e.push("text","",0),s.content=e.md.normalizeLinkText(n),s=e.push("link_close","a",-1),s.markup="autolink",s.info="auto"),e.pos+=n.length+2,!0):!1):!1}});var qc=ne((m0,Vc)=>{"use strict";var np=ls().HTML_TAG_RE;function ip(r){return/^<a[>\s]/i.test(r)}function op(r){return/^<\/a\s*>/i.test(r)}function sp(r){var e=r|32;return e>=97&&e<=122}Vc.exports=function(e,t){var n,i,s,o,a=e.pos;return!e.md.options.html||(s=e.posMax,e.src.charCodeAt(a)!==60||a+2>=s)||(n=e.src.charCodeAt(a+1),n!==33&&n!==63&&n!==47&&!sp(n))||(i=e.src.slice(a).match(np),!i)?!1:(t||(o=e.push("html_inline","",0),o.content=e.src.slice(a,a+i[0].length),ip(o.content)&&e.linkLevel++,op(o.content)&&e.linkLevel--),e.pos+=i[0].length,!0)}});var Kc=ne((g0,Yc)=>{"use strict";var Gc=Qo(),ap=Be().has,lp=Be().isValidEntityCode,Wc=Be().fromCodePoint,cp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,up=/^&([a-z][a-z0-9]{1,31});/i;Yc.exports=function(e,t){var n,i,s,o,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(s=e.src.slice(a).match(cp),s)return t||(i=s[1][0].toLowerCase()==="x"?parseInt(s[1].slice(1),16):parseInt(s[1],10),o=e.push("text_special","",0),o.content=lp(i)?Wc(i):Wc(65533),o.markup=s[0],o.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(up),s&&ap(Gc,s[1]))return t||(o=e.push("text_special","",0),o.content=Gc[s[1]],o.markup=s[0],o.info="entity"),e.pos+=s[0].length,!0;return!1}});var Qc=ne((v0,Zc)=>{"use strict";function Xc(r,e){var t,n,i,s,o,a,l,c,u={},d=e.length;if(d){var h=0,f=-2,p=[];for(t=0;t<d;t++)if(i=e[t],p.push(0),(e[h].marker!==i.marker||f!==i.token-1)&&(h=t),f=i.token,i.length=i.length||0,!!i.close){for(u.hasOwnProperty(i.marker)||(u[i.marker]=[-1,-1,-1,-1,-1,-1]),o=u[i.marker][(i.open?3:0)+i.length%3],n=h-p[h]-1,a=n;n>o;n-=p[n]+1)if(s=e[n],s.marker===i.marker&&s.open&&s.end<0&&(l=!1,(s.close||i.open)&&(s.length+i.length)%3===0&&(s.length%3!==0||i.length%3!==0)&&(l=!0),!l)){c=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+c,p[n]=c,i.open=!1,s.end=t,s.close=!1,a=-1,f=-2;break}a!==-1&&(u[i.marker][(i.open?3:0)+(i.length||0)%3]=a)}}}Zc.exports=function(e){var t,n=e.tokens_meta,i=e.tokens_meta.length;for(Xc(e,e.delimiters),t=0;t<i;t++)n[t]&&n[t].delimiters&&Xc(e,n[t].delimiters)}});var eu=ne((y0,Jc)=>{"use strict";Jc.exports=function(e){var t,n,i=0,s=e.tokens,o=e.tokens.length;for(t=n=0;t<o;t++)s[t].nesting<0&&i--,s[t].level=i,s[t].nesting>0&&i++,s[t].type==="text"&&t+1<o&&s[t+1].type==="text"?s[t+1].content=s[t].content+s[t+1].content:(t!==n&&(s[n]=s[t]),n++);t!==n&&(s.length=n)}});var ou=ne((b0,iu)=>{"use strict";var vs=ki(),tu=Be().isWhiteSpace,ru=Be().isPunctChar,nu=Be().isMdAsciiPunct;function cn(r,e,t,n){this.src=r,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}cn.prototype.pushPending=function(){var r=new vs("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};cn.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new vs(r,e,t),i=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=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(i),n};cn.prototype.scanDelims=function(r,e){var t=r,n,i,s,o,a,l,c,u,d,h=!0,f=!0,p=this.posMax,v=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===v;)t++;return s=t-r,i=t<p?this.src.charCodeAt(t):32,c=nu(n)||ru(String.fromCharCode(n)),d=nu(i)||ru(String.fromCharCode(i)),l=tu(n),u=tu(i),u?h=!1:d&&(l||c||(h=!1)),l?f=!1:c&&(u||d||(f=!1)),e?(o=h,a=f):(o=h&&(!f||c),a=f&&(!h||d)),{can_open:o,can_close:a,length:s}};cn.prototype.Token=vs;iu.exports=cn});var lu=ne((x0,au)=>{"use strict";var su=Si(),ys=[["text",Tc()],["linkify",Dc()],["newline",Fc()],["escape",Oc()],["backticks",Mc()],["strikethrough",hs().tokenize],["emphasis",ps().tokenize],["link",Nc()],["image",zc()],["autolink",Hc()],["html_inline",qc()],["entity",Kc()]],bs=[["balance_pairs",Qc()],["strikethrough",hs().postProcess],["emphasis",ps().postProcess],["fragments_join",eu()]];function un(){var r;for(this.ruler=new su,r=0;r<ys.length;r++)this.ruler.push(ys[r][0],ys[r][1]);for(this.ruler2=new su,r=0;r<bs.length;r++)this.ruler2.push(bs[r][0],bs[r][1])}un.prototype.skipToken=function(r){var e,t,n=r.pos,i=this.ruler.getRules(""),s=i.length,o=r.md.options.maxNesting,a=r.cache;if(typeof a[n]<"u"){r.pos=a[n];return}if(r.level<o)for(t=0;t<s&&(r.level++,e=i[t](r,!0),r.level--,!e);t++);else r.pos=r.posMax;e||r.pos++,a[n]=r.pos};un.prototype.tokenize=function(r){for(var e,t,n=this.ruler.getRules(""),i=n.length,s=r.posMax,o=r.md.options.maxNesting;r.pos<s;){if(r.level<o)for(t=0;t<i&&(e=n[t](r,!1),!e);t++);if(e){if(r.pos>=s)break;continue}r.pending+=r.src[r.pos++]}r.pending&&r.pushPending()};un.prototype.parse=function(r,e,t,n){var i,s,o,a=new this.State(r,e,t,n);for(this.tokenize(a),s=this.ruler2.getRules(""),o=s.length,i=0;i<o;i++)s[i](a)};un.prototype.State=ou();au.exports=un});var uu=ne((w0,cu)=>{"use strict";cu.exports=function(r){var e={};r=r||{},e.src_Any=es().source,e.src_Cc=ts().source,e.src_Z=rs().source,e.src_P=bi().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+")(?!"+(r["---"]?"-(?!--)|":"-|")+"_|:\\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+"|[.]|$)|"+(r["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+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 mu=ne((E0,pu)=>{"use strict";function xs(r){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(n){r[n]=t[n]})}),r}function Ri(r){return Object.prototype.toString.call(r)}function dp(r){return Ri(r)==="[object String]"}function hp(r){return Ri(r)==="[object Object]"}function fp(r){return Ri(r)==="[object RegExp]"}function du(r){return Ri(r)==="[object Function]"}function pp(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var fu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function mp(r){return Object.keys(r||{}).reduce(function(e,t){return e||fu.hasOwnProperty(t)},!1)}var gp={"http:":{validate:function(r,e,t){var n=r.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(r,e,t){var n=r.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&&r[e-3]===":"||e>=3&&r[e-3]==="/"?0:n.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(r,e,t){var n=r.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}}},vp="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]",yp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function bp(r){r.__index__=-1,r.__text_cache__=""}function xp(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function hu(){return function(r,e){e.normalize(r)}}function Fi(r){var e=r.re=uu()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(vp),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 i=[];r.__compiled__={};function s(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(r.__schemas__).forEach(function(a){var l=r.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(r.__compiled__[a]=c,hp(l)){fp(l.validate)?c.validate=xp(l.validate):du(l.validate)?c.validate=l.validate:s(a,l),du(l.normalize)?c.normalize=l.normalize:l.normalize?s(a,l):c.normalize=hu();return}if(dp(l)){i.push(a);return}s(a,l)}}),i.forEach(function(a){r.__compiled__[r.__schemas__[a]]&&(r.__compiled__[a].validate=r.__compiled__[r.__schemas__[a]].validate,r.__compiled__[a].normalize=r.__compiled__[r.__schemas__[a]].normalize)}),r.__compiled__[""]={validate:null,normalize:hu()};var o=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(pp).join("|");r.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+o+")","i"),r.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+o+")","ig"),r.re.schema_at_start=RegExp("^"+r.re.schema_search.source,"i"),r.re.pretest=RegExp("("+r.re.schema_test.source+")|("+r.re.host_fuzzy_test.source+")|@","i"),bp(r)}function wp(r,e){var t=r.__index__,n=r.__last_index__,i=r.__text_cache__.slice(t,n);this.schema=r.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=n+e,this.raw=i,this.text=i,this.url=i}function ws(r,e){var t=new wp(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function At(r,e){if(!(this instanceof At))return new At(r,e);e||mp(r)&&(e=r,r={}),this.__opts__=xs({},fu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=xs({},gp,r),this.__compiled__={},this.__tlds__=yp,this.__tlds_replaced__=!1,this.re={},Fi(this)}At.prototype.add=function(e,t){return this.__schemas__[e]=t,Fi(this),this};At.prototype.set=function(e){return this.__opts__=xs(this.__opts__,e),this};At.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,i,s,o,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(s=this.testSchemaAt(e,t[2],l.lastIndex),s){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+s;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&&(o=n.index+n[1].length,(this.__index__<0||o<this.__index__)&&(this.__schema__="",this.__index__=o,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(i=e.match(this.re.email_fuzzy))!==null&&(o=i.index+i[1].length,a=i.index+i[0].length,(this.__index__<0||o<this.__index__||o===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=o,this.__last_index__=a))),this.__index__>=0};At.prototype.pretest=function(e){return this.re.pretest.test(e)};At.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};At.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(ws(this,t)),t=this.__last_index__);for(var i=t?e.slice(t):e;this.test(i);)n.push(ws(this,t)),i=i.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};At.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,ws(this,0)):null};At.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(n,i,s){return n!==s[i-1]}).reverse(),Fi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Fi(this),this)};At.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};At.prototype.onCompile=function(){};pu.exports=At});var Cu={};bo(Cu,{decode:()=>As,default:()=>Dp,encode:()=>ks,toASCII:()=>Eu,toUnicode:()=>wu,ucs2decode:()=>Ss,ucs2encode:()=>bu});function or(r){throw new RangeError(Ap[r])}function kp(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function yu(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(Sp,".");let i=r.split("."),s=kp(i,e).join(".");return n+s}function Ss(r){let e=[],t=0,n=r.length;for(;t<n;){let i=r.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){let s=r.charCodeAt(t++);(s&64512)==56320?e.push(((i&1023)<<10)+(s&1023)+65536):(e.push(i),t--)}else e.push(i)}return e}var vu,Ep,Cp,Sp,Ap,Es,Ht,Cs,bu,Tp,gu,xu,As,ks,wu,Eu,Ip,Dp,Su=Od(()=>{"use strict";vu="-",Ep=/^xn--/,Cp=/[^\0-\x7F]/,Sp=/[\x2E\u3002\uFF0E\uFF61]/g,Ap={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Es=36-1,Ht=Math.floor,Cs=String.fromCharCode;bu=r=>String.fromCodePoint(...r),Tp=function(r){return r>=48&&r<58?26+(r-48):r>=65&&r<91?r-65:r>=97&&r<123?r-97:36},gu=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},xu=function(r,e,t){let n=0;for(r=t?Ht(r/700):r>>1,r+=Ht(r/e);r>Es*26>>1;n+=36)r=Ht(r/Es);return Ht(n+(Es+1)*r/(r+38))},As=function(r){let e=[],t=r.length,n=0,i=128,s=72,o=r.lastIndexOf(vu);o<0&&(o=0);for(let a=0;a<o;++a)r.charCodeAt(a)>=128&&or("not-basic"),e.push(r.charCodeAt(a));for(let a=o>0?o+1:0;a<t;){let l=n;for(let u=1,d=36;;d+=36){a>=t&&or("invalid-input");let h=Tp(r.charCodeAt(a++));h>=36&&or("invalid-input"),h>Ht((2147483647-n)/u)&&or("overflow"),n+=h*u;let f=d<=s?1:d>=s+26?26:d-s;if(h<f)break;let p=36-f;u>Ht(2147483647/p)&&or("overflow"),u*=p}let c=e.length+1;s=xu(n-l,c,l==0),Ht(n/c)>2147483647-i&&or("overflow"),i+=Ht(n/c),n%=c,e.splice(n++,0,i)}return String.fromCodePoint(...e)},ks=function(r){let e=[];r=Ss(r);let t=r.length,n=128,i=0,s=72;for(let l of r)l<128&&e.push(Cs(l));let o=e.length,a=o;for(o&&e.push(vu);a<t;){let l=2147483647;for(let u of r)u>=n&&u<l&&(l=u);let c=a+1;l-n>Ht((2147483647-i)/c)&&or("overflow"),i+=(l-n)*c,n=l;for(let u of r)if(u<n&&++i>2147483647&&or("overflow"),u===n){let d=i;for(let h=36;;h+=36){let f=h<=s?1:h>=s+26?26:h-s;if(d<f)break;let p=d-f,v=36-f;e.push(Cs(gu(f+p%v,0))),d=Ht(p/v)}e.push(Cs(gu(d,0))),s=xu(i,c,a===o),i=0,++a}++i,++n}return e.join("")},wu=function(r){return yu(r,function(e){return Ep.test(e)?As(e.slice(4).toLowerCase()):e})},Eu=function(r){return yu(r,function(e){return Cp.test(e)?"xn--"+ks(e):e})},Ip={version:"2.1.0",ucs2:{decode:Ss,encode:bu},decode:As,encode:ks,toASCII:Eu,toUnicode:wu},Dp=Ip});var ku=ne((C0,Au)=>{"use strict";Au.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 Iu=ne((S0,Tu)=>{"use strict";Tu.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 Lu=ne((A0,Du)=>{"use strict";Du.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 Pu=ne((k0,Ou)=>{"use strict";var dn=Be(),Lp=fl(),Fp=ml(),Rp=jl(),Op=Ac(),Pp=lu(),Mp=mu(),pr=Jo(),Fu=(Su(),Pd(Cu)),$p={default:ku(),zero:Iu(),commonmark:Lu()},_p=/^(vbscript|javascript|file|data):/,Bp=/^data:image\/(gif|png|jpeg|webp);/;function Np(r){var e=r.trim().toLowerCase();return _p.test(e)?!!Bp.test(e):!0}var Ru=["http:","https:","mailto:"];function Up(r){var e=pr.parse(r,!0);if(e.hostname&&(!e.protocol||Ru.indexOf(e.protocol)>=0))try{e.hostname=Fu.toASCII(e.hostname)}catch{}return pr.encode(pr.format(e))}function zp(r){var e=pr.parse(r,!0);if(e.hostname&&(!e.protocol||Ru.indexOf(e.protocol)>=0))try{e.hostname=Fu.toUnicode(e.hostname)}catch{}return pr.decode(pr.format(e),pr.decode.defaultChars+"%")}function Dt(r,e){if(!(this instanceof Dt))return new Dt(r,e);e||dn.isString(r)||(e=r||{},r="default"),this.inline=new Pp,this.block=new Op,this.core=new Rp,this.renderer=new Fp,this.linkify=new Mp,this.validateLink=Np,this.normalizeLink=Up,this.normalizeLinkText=zp,this.utils=dn,this.helpers=dn.assign({},Lp),this.options={},this.configure(r),e&&this.set(e)}Dt.prototype.set=function(r){return dn.assign(this.options,r),this};Dt.prototype.configure=function(r){var e=this,t;if(dn.isString(r)&&(t=r,r=$p[t],!r))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!r)throw new Error("Wrong `markdown-it` preset, can't be empty");return r.options&&e.set(r.options),r.components&&Object.keys(r.components).forEach(function(n){r.components[n].rules&&e[n].ruler.enableOnly(r.components[n].rules),r.components[n].rules2&&e[n].ruler2.enableOnly(r.components[n].rules2)}),this};Dt.prototype.enable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(i){t=t.concat(this[i].ruler.enable(r,!0))},this),t=t.concat(this.inline.ruler2.enable(r,!0));var n=r.filter(function(i){return t.indexOf(i)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this};Dt.prototype.disable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(i){t=t.concat(this[i].ruler.disable(r,!0))},this),t=t.concat(this.inline.ruler2.disable(r,!0));var n=r.filter(function(i){return t.indexOf(i)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this};Dt.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};Dt.prototype.parse=function(r,e){if(typeof r!="string")throw new Error("Input data should be a String");var t=new this.core.State(r,this,e);return this.core.process(t),t.tokens};Dt.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};Dt.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};Dt.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};Ou.exports=Dt});var $u=ne((T0,Mu)=>{"use strict";Mu.exports=Pu()});var zu=ne((I0,Uu)=>{var Ts=!0,Bu=!1,Nu=!1;Uu.exports=function(r,e){e&&(Ts=!e.enabled,Bu=!!e.label,Nu=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,i=2;i<n.length;i++)Hp(n,i)&&(Vp(n[i],t.Token),_u(n[i-2],"class","task-list-item"+(Ts?"":" enabled")),_u(n[jp(n,i-2)],"class","contains-task-list"))})};function _u(r,e,t){var n=r.attrIndex(e),i=[e,t];n<0?r.attrPush(i):r.attrs[n]=i}function jp(r,e){for(var t=r[e].level-1,n=e-1;n>=0;n--)if(r[n].level===t)return n;return-1}function Hp(r,e){return Kp(r[e])&&Xp(r[e-1])&&Zp(r[e-2])&&Qp(r[e])}function Vp(r,e){if(r.children.unshift(qp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),Bu)if(Nu){r.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);r.children[0].content=r.children[0].content.slice(0,-1)+' id="'+t+'">',r.children.push(Yp(r.content,t,e))}else r.children.unshift(Gp(e)),r.children.push(Wp(e))}function qp(r,e){var t=new e("html_inline","",0),n=Ts?' disabled="" ':"";return r.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+n+'type="checkbox">':(r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+n+'type="checkbox">'),t}function Gp(r){var e=new r("html_inline","",0);return e.content="<label>",e}function Wp(r){var e=new r("html_inline","",0);return e.content="</label>",e}function Yp(r,e,t){var n=new t("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+e+'">'+r+"</label>",n.attrs=[{for:e}],n}function Kp(r){return r.type==="inline"}function Xp(r){return r.type==="paragraph_open"}function Zp(r){return r.type==="list_item_open"}function Qp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var nd=ne((mn,Bs)=>{(function(r,e){typeof mn=="object"&&typeof Bs=="object"?Bs.exports=e():typeof define=="function"&&define.amd?define([],e):typeof mn=="object"?mn.ClipboardJS=e():r.ClipboardJS=e()})(mn,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return S}});var l=s(279),o=s.n(l),l=s(370),a=s.n(l),l=s(817),c=s.n(l);function u(O){try{return document.execCommand(O)}catch{return}}var d=function(O){return O=c()(O),u("cut"),O};function h(P,A){var D,I,P=(D=P,I=document.documentElement.getAttribute("dir")==="rtl",(P=document.createElement("textarea")).style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[I?"right":"left"]="-9999px",I=window.pageYOffset||document.documentElement.scrollTop,P.style.top="".concat(I,"px"),P.setAttribute("readonly",""),P.value=D,P);return A.container.appendChild(P),A=c()(P),u("copy"),P.remove(),A}var f=function(O){var A=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof O=="string"?D=h(O,A):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O?.type)?D=h(O.value,A):(D=c()(O),u("copy")),D};function p(O){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}var v=function(){var I=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=I.action,O=D===void 0?"copy":D,A=I.container,D=I.target,I=I.text;if(O!=="copy"&&O!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0){if(!D||p(D)!=="object"||D.nodeType!==1)throw new Error('Invalid "target" value, use a valid Element');if(O==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(O==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}return I?f(I,{container:A}):D?O==="cut"?d(D):f(D,{container:A}):void 0};function y(O){return(y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}function b(O,A){for(var D=0;D<A.length;D++){var I=A[D];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(O,I.key,I)}}function x(O,A){return(x=Object.setPrototypeOf||function(D,I){return D.__proto__=I,D})(O,A)}function T(O){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var D,I=E(O);return D=A?(D=E(this).constructor,Reflect.construct(I,arguments,D)):I.apply(this,arguments),I=this,!(D=D)||y(D)!=="object"&&typeof D!="function"?function(P){if(P!==void 0)return P;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(I):D}}function E(O){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(O)}function M(O,A){if(O="data-clipboard-".concat(O),A.hasAttribute(O))return A.getAttribute(O)}var S=function(){(function(_,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function");_.prototype=Object.create(B&&B.prototype,{constructor:{value:_,writable:!0,configurable:!0}}),B&&x(_,B)})(P,o());var O,A,D,I=T(P);function P(_,B){var H;return function(Q){if(!(Q instanceof P))throw new TypeError("Cannot call a class as a function")}(this),(H=I.call(this)).resolveOptions(B),H.listenClick(_),H}return O=P,D=[{key:"copy",value:function(_){var B=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return f(_,B)}},{key:"cut",value:function(_){return d(_)}},{key:"isSupported",value:function(){var _=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],_=typeof _=="string"?[_]:_,B=!!document.queryCommandSupported;return _.forEach(function(H){B=B&&!!document.queryCommandSupported(H)}),B}}],(A=[{key:"resolveOptions",value:function(){var _=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof _.action=="function"?_.action:this.defaultAction,this.target=typeof _.target=="function"?_.target:this.defaultTarget,this.text=typeof _.text=="function"?_.text:this.defaultText,this.container=y(_.container)==="object"?_.container:document.body}},{key:"listenClick",value:function(_){var B=this;this.listener=a()(_,"click",function(H){return B.onClick(H)})}},{key:"onClick",value:function(Q){var B=Q.delegateTarget||Q.currentTarget,H=this.action(B)||"copy",Q=v({action:H,container:this.container,target:this.target(B),text:this.text(B)});this.emit(Q?"success":"error",{action:H,text:Q,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(_){return M("action",_)}},{key:"defaultTarget",value:function(_){if(_=M("target",_),_)return document.querySelector(_)}},{key:"defaultText",value:function(_){return M("text",_)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(O.prototype,A),D&&b(O,D),P}()},828:function(n){var i;typeof Element>"u"||Element.prototype.matches||((i=Element.prototype).matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector),n.exports=function(s,o){for(;s&&s.nodeType!==9;){if(typeof s.matches=="function"&&s.matches(o))return s;s=s.parentNode}}},438:function(n,i,s){var o=s(828);function a(l,c,u,d,h){var f=function(p,v,y,b){return function(x){x.delegateTarget=o(x.target,v),x.delegateTarget&&b.call(p,x)}}.apply(this,arguments);return l.addEventListener(u,f,h),{destroy:function(){l.removeEventListener(u,f,h)}}}n.exports=function(l,c,u,d,h){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof u=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(f){return a(f,c,u,d,h)}))}},879:function(n,i){i.node=function(s){return s!==void 0&&s instanceof HTMLElement&&s.nodeType===1},i.nodeList=function(s){var o=Object.prototype.toString.call(s);return s!==void 0&&(o==="[object NodeList]"||o==="[object HTMLCollection]")&&"length"in s&&(s.length===0||i.node(s[0]))},i.string=function(s){return typeof s=="string"||s instanceof String},i.fn=function(s){return Object.prototype.toString.call(s)==="[object Function]"}},370:function(n,i,s){var o=s(879),a=s(438);n.exports=function(l,c,u){if(!l&&!c&&!u)throw new Error("Missing required arguments");if(!o.string(c))throw new TypeError("Second argument must be a String");if(!o.fn(u))throw new TypeError("Third argument must be a Function");if(o.node(l))return v=c,y=u,(p=l).addEventListener(v,y),{destroy:function(){p.removeEventListener(v,y)}};if(o.nodeList(l))return d=l,h=c,f=u,Array.prototype.forEach.call(d,function(b){b.addEventListener(h,f)}),{destroy:function(){Array.prototype.forEach.call(d,function(b){b.removeEventListener(h,f)})}};if(o.string(l))return l=l,c=c,u=u,a(document.body,l,c,u);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var d,h,f,p,v,y}},817:function(n){n.exports=function(i){var s,o=i.nodeName==="SELECT"?(i.focus(),i.value):i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"?((s=i.hasAttribute("readonly"))||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),s||i.removeAttribute("readonly"),i.value):(i.hasAttribute("contenteditable")&&i.focus(),o=window.getSelection(),(s=document.createRange()).selectNodeContents(i),o.removeAllRanges(),o.addRange(s),o.toString());return o}},279:function(n){function i(){}i.prototype={on:function(s,o,a){var l=this.e||(this.e={});return(l[s]||(l[s]=[])).push({fn:o,ctx:a}),this},once:function(s,o,a){var l=this;function c(){l.off(s,c),o.apply(a,arguments)}return c._=o,this.on(s,c,a)},emit:function(s){for(var o=[].slice.call(arguments,1),a=((this.e||(this.e={}))[s]||[]).slice(),l=0,c=a.length;l<c;l++)a[l].fn.apply(a[l].ctx,o);return this},off:function(s,o){var a=this.e||(this.e={}),l=a[s],c=[];if(l&&o)for(var u=0,d=l.length;u<d;u++)l[u].fn!==o&&l[u].fn._!==o&&c.push(l[u]);return c.length?a[s]=c:delete a[s],this}},n.exports=i,n.exports.TinyEmitter=i}},t={},r.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(i,{a:i}),i},r.d=function(n,i){for(var s in i)r.o(i,s)&&!r.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:i[s]})},r.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},r(686).default;function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}var e,t})});var Br={},$d=[];function Nr(r,e){if($d.push({name:r,data:e}),typeof Br[r]>"u")return this;let t=Br[r];for(let n=0;n<t.length;n++){let i=t[n];i(e)}}function _d(r,e){typeof Br[r]>"u"&&(Br[r]=[]),Br[r].push(e)}function Bd(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function Nd(r){if(r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
-`);Nr("error",e)}}function Ud(r){r.status&&r.status>=400&&r.data&&r.data.message&&Nr("error",r.data.message)}var qs={emit:Nr,emitPublic:Bd,listen:_d,success:r=>Nr("success",r),error:r=>Nr("error",r),showValidationErrors:Nd,showResponseError:Ud};async function zd(r,e={}){return Gs(r,{method:"GET",params:e})}async function jd(r,e=null){return yn("POST",r,e)}async function Hd(r,e=null){return yn("PUT",r,e)}async function Vd(r,e=null){return yn("PATCH",r,e)}async function qd(r,e=null){return yn("DELETE",r,e)}async function yn(r,e,t=null){let n={method:r,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&&r!=="post"&&(t.append("_method",r),n.method="post"),Gs(e,n)}async function Gs(r,e={}){if(r.startsWith("http")||(r=window.baseUrl(r)),e.params){let o=new URL(r);for(let a of Object.keys(e.params)){let l=e.params[a];typeof l<"u"&&l!==null&&o.searchParams.set(a,l)}r=o.toString()}let t=document.querySelector("meta[name=token]").getAttribute("content");e=Object.assign({},e,{credentials:"same-origin"}),e.headers=Object.assign({},e.headers||{},{baseURL:window.baseUrl(""),"X-CSRF-TOKEN":t});let n=await fetch(r,e),i=await Gd(n),s={data:i,headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,url:n.url,original:n};if(!n.ok)throw new vn(n,i);return s}async function Gd(r){if(r.status===204)return null;let t=(r.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?await r.json():await r.text()}var vn=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}},Ws={get:zd,post:jd,put:Hd,patch:Vd,delete:qd,HttpError:vn};var wo=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),i=t.getAttribute("value");this.store.set(n,i)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let i=this.getTransText(e);return this.parsePlural(i,t,n)}parsePlural(e,t,n){let i=e.split("|"),s=/^{([0-9]+)}/,o=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of i){let c=l.match(s);if(c!==null&&Number(c[1])===t){a=l.replace(s,"").trim();break}let u=l.match(o);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(o,"").trim();break}}return a===null&&i.length>1&&(a=t===1?i[0]:i[1]),a===null&&(a=i[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);return n===null||n.forEach(i=>{let s=i.substring(1);typeof t[s]>"u"||(e=e.replace(i,t[s]))}),e}},Ys=wo;var ko={};bo(ko,{first:()=>Xd,firstOnElement:()=>Qd,get:()=>Zd,init:()=>So,register:()=>Ao});function Eo(r){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=r.split("-");return t[0]+t.slice(1).map(e).join("")}function Ks(r){return r.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var Ur={},Xs={},Co=new WeakMap;function Wd(r,e){let t=Xs[r];if(t===void 0)return;let n;try{n=new t,n.$name=r,n.$el=e;let s=Yd(r,e);n.$refs=s.refs,n.$manyRefs=s.manyRefs,n.$opts=Kd(r,e),n.setup()}catch(s){console.error("Failed to create component",s,r,e)}typeof Ur[r]>"u"&&(Ur[r]=[]),Ur[r].push(n);let i=Co.get(e)||{};i[r]=n,Co.set(e,i)}function Yd(r,e){let t={},n={},i=`${r}@`,s=`[refs*="${i}"]`,o=[...e.querySelectorAll(s)];e.matches(s)&&o.push(e);for(let a of o){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(i)).map(c=>c.replace(i,"")).map(Eo);for(let c of l)t[c]=a,typeof n[c]>"u"&&(n[c]=[]),n[c].push(a)}return{refs:t,manyRefs:n}}function Kd(r,e){let t={},n=`option:${r}:`;for(let{name:i,value:s}of e.attributes)if(i.startsWith(n)){let o=i.replace(n,"");t[Eo(o)]=s||""}return t}function So(r=document){let e=r.querySelectorAll("[component],[components]");for(let t of e){let n=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let i of n)Wd(i,t)}}function Ao(r){let e=Object.keys(r);for(let t of e)Xs[Ks(t)]=r[t]}function Xd(r){return(Ur[r]||[null])[0]}function Zd(r){return Ur[r]||[]}function Qd(r,e){return(Co.get(r)||{})[e]||null}var zs={};bo(zs,{AddRemoveRows:()=>wn,AjaxDeleteRow:()=>En,AjaxForm:()=>Cn,Attachments:()=>Sn,AttachmentsList:()=>An,AutoSubmit:()=>Tn,AutoSuggest:()=>kn,BackToTop:()=>In,BookSort:()=>Gn,ChapterContents:()=>Kn,CodeEditor:()=>Xn,CodeHighlighter:()=>Zn,CodeTextarea:()=>Qn,Collapsible:()=>Jn,ConfirmDialog:()=>ei,CustomCheckbox:()=>ti,DetailsHighlighter:()=>ri,Dropdown:()=>ni,DropdownSearch:()=>ii,Dropzone:()=>si,EditorToolbox:()=>ai,EntityPermissions:()=>li,EntitySearch:()=>ci,EntitySelector:()=>ui,EntitySelectorPopup:()=>di,EventEmitSelect:()=>hi,ExpandToggle:()=>fi,GlobalSearch:()=>pi,HeaderMobileToggle:()=>mi,ImageManager:()=>gi,ImagePicker:()=>vi,ListSortControl:()=>yi,MarkdownEditor:()=>Ui,NewUserPassword:()=>zi,Notification:()=>ji,OptionalInput:()=>Hi,PageComments:()=>Vi,PageDisplay:()=>qi,PageEditor:()=>Gi,PagePicker:()=>Yi,PermissionsTable:()=>Ki,Pointer:()=>Xi,Popup:()=>Zi,SettingAppColorScheme:()=>Qi,SettingColorPicker:()=>Ji,SettingHomepageControl:()=>eo,ShelfSort:()=>to,ShortcutInput:()=>no,Shortcuts:()=>ro,SortableList:()=>io,SubmitOnChange:()=>oo,Tabs:()=>so,TagManager:()=>ao,TemplateManager:()=>lo,ToggleSwitch:()=>co,TriLayout:()=>uo,UserSelect:()=>ho,WebhookEvents:()=>fo,WysiwygEditor:()=>go});function To(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function bn(r,e,t){for(let n of e)r.addEventListener(n,t)}function je(r,e){Array.isArray(r)||(r=[r]);for(let t of r)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function xn(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function Ge(r,e,t,n){r.addEventListener(t,function(i){let s=i.target.closest(e);s&&n.call(s,i,s)})}function Zs(r,e){let t=document.querySelectorAll(r);e=e.toLowerCase();for(let n of t)if(n.textContent.toLowerCase().includes(e))return n;return null}function zr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Qs(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function tr(r){let e=document.createElement("div");return e.innerHTML=r,window.$components.init(e),e.children[0]}function Bt(r,e,t){let n;return function(){let i=this,s=arguments,o=function(){n=null,t||r.apply(i,s)},a=t&&!n;clearTimeout(n),n=setTimeout(o,e),a&&r.apply(i,s)}}function jr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(r).getPropertyValue("background-color");r.style.backgroundColor=e,setTimeout(()=>{r.classList.add("selectFade"),r.style.backgroundColor=t},10),setTimeout(()=>{r.classList.remove("selectFade"),r.style.backgroundColor=""},3e3)}function Js(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ea(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var V=class{constructor(){br(this,"$name","");br(this,"$el",null);br(this,"$refs",{});br(this,"$manyRefs",{});br(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,i=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(i)}};var wn=class extends V{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)),Ge(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=ea(),n=e.querySelectorAll('[name*="randrowid"]');for(let i of n)i.name=i.name.split("randrowid").join(t)}};var En=class extends V{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,je(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(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var Cn=class extends V{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}xn(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>je(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 Sn=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-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",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),i=JSON.parse(n);window.$events.emit("editor::insert",{html:i["text/html"],markdown:i["text/plain"]})})}reloadList(){this.stopEdit(),window.$components.firstOnElement(this.mainTabs,"tabs").show("attachment-panel-items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(t=>{this.list.innerHTML=t.data,window.$components.init(this.list)})}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.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),zr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}};var An=class extends V{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=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 Do={},kn=class extends V{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(){this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()}),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.container.addEventListener("keydown",this.containerKeyDown.bind(this)),Ge(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),Ge(this.list,"button","keydown",(e,t)=>{e.key==="Enter"&&this.selectSuggestion(t.textContent)})}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()}containerKeyDown(e){e.key==="Enter"&&e.preventDefault(),!this.list.classList.contains("hidden")&&(e.key==="ArrowDown"?(this.moveFocus(!0),e.preventDefault()):e.key==="ArrowUp"?(this.moveFocus(!1),e.preventDefault()):e.key==="Escape"&&(this.hideSuggestions(),e.preventDefault()))}moveFocus(e=!0){let t=Array.from(this.container.querySelectorAll("input,button")),n=t.indexOf(document.activeElement),i=t[n+(e?1:-1)];i&&i.focus()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.toLowerCase(),i=(await this.loadSuggestions(t,e)).filter(s=>t===""||s.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(i)}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},i=`${this.url}:${JSON.stringify(n)}`;if(Do[i])return Do[i];let s=await window.$http.get(this.url,n);return Do[i]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`<li><button type="button" class="text-item">${Js(t)}</button></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll("button"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var Tn=class extends V{setup(){this.form=this.$el,this.form.submit()}};var In=class extends V{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,i=Date.now(),s=this.targetElem.getBoundingClientRect().top;function o(){let a=1-(Date.now()-i)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(o.bind(this))):t.scrollTop=e}requestAnimationFrame(o.bind(this))}};function ta(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function Ut(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ta(Object(t),!0).forEach(function(n){Jd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ta(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Mn(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Mn=function(e){return typeof e}:Mn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mn(r)}function Jd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Pt(){return Pt=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Pt.apply(this,arguments)}function eh(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function th(r,e){if(r==null)return{};var t=eh(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i<s.length;i++)n=s[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function rh(r){return nh(r)||ih(r)||oh(r)||sh()}function nh(r){if(Array.isArray(r))return Uo(r)}function ih(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function oh(r,e){if(r){if(typeof r=="string")return Uo(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Uo(r,e)}}function Uo(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function sh(){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 ah="1.15.0";function Kt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Xt=Kt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),tn=Kt(/Edge/i),ra=Kt(/firefox/i),Xr=Kt(/safari/i)&&!Kt(/chrome/i)&&!Kt(/android/i),ha=Kt(/iP(ad|od|hone)/i),fa=Kt(/chrome/i)&&Kt(/android/i),pa={capture:!1,passive:!1};function De(r,e,t){r.addEventListener(e,t,!Xt&&pa)}function Te(r,e,t){r.removeEventListener(e,t,!Xt&&pa)}function Un(r,e){if(e){if(e[0]===">"&&(e=e.substring(1)),r)try{if(r.matches)return r.matches(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e)}catch{return!1}return!1}}function lh(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Ot(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&Un(r,e):Un(r,e))||n&&r===t)return r;if(r===t)break}while(r=lh(r))}return null}var na=/\s+/g;function it(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(na," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(na," ")}}function ue(r,e,t){var n=r&&r.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(r,""):r.currentStyle&&(t=r.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 dr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ue(r,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(r=r.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(t)}function ma(r,e,t){if(r){var n=r.getElementsByTagName(e),i=0,s=n.length;if(t)for(;i<s;i++)t(n[i],i);return n}return[]}function Nt(){var r=document.scrollingElement;return r||document.documentElement}function Ke(r,e,t,n,i){if(!(!r.getBoundingClientRect&&r!==window)){var s,o,a,l,c,u,d;if(r!==window&&r.parentNode&&r!==Nt()?(s=r.getBoundingClientRect(),o=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,d=s.width):(o=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,d=window.innerWidth),(e||t)&&r!==window&&(i=i||r.parentNode,!Xt))do if(i&&i.getBoundingClientRect&&(ue(i,"transform")!=="none"||t&&ue(i,"position")!=="static")){var h=i.getBoundingClientRect();o-=h.top+parseInt(ue(i,"border-top-width")),a-=h.left+parseInt(ue(i,"border-left-width")),l=o+s.height,c=a+s.width;break}while(i=i.parentNode);if(n&&r!==window){var f=dr(i||r),p=f&&f.a,v=f&&f.d;f&&(o/=v,a/=p,d/=p,u/=v,l=o+u,c=a+d)}return{top:o,left:a,bottom:l,right:c,width:d,height:u}}}function ia(r,e,t){for(var n=ir(r,!0),i=Ke(r)[e];n;){var s=Ke(n)[t],o=void 0;if(t==="top"||t==="left"?o=i>=s:o=i<=s,!o)return n;if(n===Nt())break;n=ir(n,!1)}return!1}function Ar(r,e,t,n){for(var i=0,s=0,o=r.children;s<o.length;){if(o[s].style.display!=="none"&&o[s]!==ye.ghost&&(n||o[s]!==ye.dragged)&&Ot(o[s],t.draggable,r,!1)){if(i===e)return o[s];i++}s++}return null}function qo(r,e){for(var t=r.lastElementChild;t&&(t===ye.ghost||ue(t,"display")==="none"||e&&!Un(t,e));)t=t.previousElementSibling;return t||null}function ot(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ye.clone&&(!e||Un(r,e))&&t++;return t}function oa(r){var e=0,t=0,n=Nt();if(r)do{var i=dr(r),s=i.a,o=i.d;e+=r.scrollLeft*s,t+=r.scrollTop*o}while(r!==n&&(r=r.parentNode));return[e,t]}function ch(r,e){for(var t in r)if(r.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r[t][n])return Number(t)}return-1}function ir(r,e){if(!r||!r.getBoundingClientRect)return Nt();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var i=ue(t);if(t.clientWidth<t.scrollWidth&&(i.overflowX=="auto"||i.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(i.overflowY=="auto"||i.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Nt();if(n||e)return t;n=!0}}while(t=t.parentNode);return Nt()}function uh(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Lo(r,e){return Math.round(r.top)===Math.round(e.top)&&Math.round(r.left)===Math.round(e.left)&&Math.round(r.height)===Math.round(e.height)&&Math.round(r.width)===Math.round(e.width)}var Zr;function ga(r,e){return function(){if(!Zr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Zr=setTimeout(function(){Zr=void 0},e)}}}function dh(){clearTimeout(Zr),Zr=void 0}function va(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Go(r){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(r).cloneNode(!0):t?t(r).clone(!0)[0]:r.cloneNode(!0)}function sa(r,e){ue(r,"position","absolute"),ue(r,"top",e.top),ue(r,"left",e.left),ue(r,"width",e.width),ue(r,"height",e.height)}function Fo(r){ue(r,"position",""),ue(r,"top",""),ue(r,"left",""),ue(r,"width",""),ue(r,"height","")}var pt="Sortable"+new Date().getTime();function hh(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(i){if(!(ue(i,"display")==="none"||i===ye.ghost)){r.push({target:i,rect:Ke(i)});var s=Ut({},r[r.length-1].rect);if(i.thisAnimationDuration){var o=dr(i,!0);o&&(s.top-=o.f,s.left-=o.e)}i.fromRect=s}})}},addAnimationState:function(n){r.push(n)},removeAnimationState:function(n){r.splice(ch(r,{target:n}),1)},animateAll:function(n){var i=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,o=0;r.forEach(function(a){var l=0,c=a.target,u=c.fromRect,d=Ke(c),h=c.prevFromRect,f=c.prevToRect,p=a.rect,v=dr(c,!0);v&&(d.top-=v.f,d.left-=v.e),c.toRect=d,c.thisAnimationDuration&&Lo(h,d)&&!Lo(u,d)&&(p.top-d.top)/(p.left-d.left)===(u.top-d.top)/(u.left-d.left)&&(l=ph(p,h,f,i.options)),Lo(d,u)||(c.prevFromRect=u,c.prevToRect=d,l||(l=i.options.animation),i.animate(c,p,d,l)),l&&(s=!0,o=Math.max(o,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),s?e=setTimeout(function(){typeof n=="function"&&n()},o):typeof n=="function"&&n(),r=[]},animate:function(n,i,s,o){if(o){ue(n,"transition",""),ue(n,"transform","");var a=dr(this.el),l=a&&a.a,c=a&&a.d,u=(i.left-s.left)/(l||1),d=(i.top-s.top)/(c||1);n.animatingX=!!u,n.animatingY=!!d,ue(n,"transform","translate3d("+u+"px,"+d+"px,0)"),this.forRepaintDummy=fh(n),ue(n,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),ue(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ue(n,"transition",""),ue(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},o)}}}}function fh(r){return r.offsetWidth}function ph(r,e,t,n){return Math.sqrt(Math.pow(e.top-r.top,2)+Math.pow(e.left-r.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var xr=[],Ro={initializeByDefault:!0},rn={mount:function(e){for(var t in Ro)Ro.hasOwnProperty(t)&&!(t in e)&&(e[t]=Ro[t]);xr.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),xr.push(e)},pluginEvent:function(e,t,n){var i=this;this.eventCanceled=!1,n.cancel=function(){i.eventCanceled=!0};var s=e+"Global";xr.forEach(function(o){t[o.pluginName]&&(t[o.pluginName][s]&&t[o.pluginName][s](Ut({sortable:t},n)),t.options[o.pluginName]&&t[o.pluginName][e]&&t[o.pluginName][e](Ut({sortable:t},n)))})},initializePlugins:function(e,t,n,i){xr.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,Pt(n,c.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var o=this.modifyOption(e,s,e.options[s]);typeof o<"u"&&(e.options[s]=o)}},getEventProperties:function(e,t){var n={};return xr.forEach(function(i){typeof i.eventProperties=="function"&&Pt(n,i.eventProperties.call(t[i.pluginName],e))}),n},modifyOption:function(e,t,n){var i;return xr.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[t]=="function"&&(i=s.optionListeners[t].call(e[s.pluginName],n))}),i}};function Gr(r){var e=r.sortable,t=r.rootEl,n=r.name,i=r.targetEl,s=r.cloneEl,o=r.toEl,a=r.fromEl,l=r.oldIndex,c=r.newIndex,u=r.oldDraggableIndex,d=r.newDraggableIndex,h=r.originalEvent,f=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[pt],!!e){var v,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Xt&&!tn?v=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(v=document.createEvent("Event"),v.initEvent(n,!0,!0)),v.to=o||t,v.from=a||t,v.item=i||t,v.clone=s,v.oldIndex=l,v.newIndex=c,v.oldDraggableIndex=u,v.newDraggableIndex=d,v.originalEvent=h,v.pullMode=f?f.lastPutMode:void 0;var x=Ut(Ut({},p),rn.getEventProperties(n,e));for(var T in x)v[T]=x[T];t&&t.dispatchEvent(v),y[b]&&y[b].call(e,v)}}var mh=["evt"],bt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=n.evt,s=th(n,mh);rn.pluginEvent.bind(ye)(e,t,Ut({dragEl:te,parentEl:tt,ghostEl:Ce,rootEl:Ye,nextEl:ur,lastDownEl:$n,cloneEl:Qe,cloneHidden:nr,dragStarted:Wr,putSortable:ct,activeSortable:ye.active,originalEvent:i,oldIndex:Sr,oldDraggableIndex:Qr,newIndex:St,newDraggableIndex:rr,hideGhostForTarget:wa,unhideGhostForTarget:Ea,cloneNowHidden:function(){nr=!0},cloneNowShown:function(){nr=!1},dispatchSortableEvent:function(a){gt({sortable:t,name:a,originalEvent:i})}},s))};function gt(r){Gr(Ut({putSortable:ct,cloneEl:Qe,targetEl:te,rootEl:Ye,oldIndex:Sr,oldDraggableIndex:Qr,newIndex:St,newDraggableIndex:rr},r))}var te,tt,Ce,Ye,ur,$n,Qe,nr,Sr,St,Qr,rr,Dn,ct,Cr=!1,zn=!1,jn=[],lr,Ft,Oo,Po,aa,la,Wr,wr,Jr,en=!1,Ln=!1,_n,ft,Mo=[],zo=!1,Hn=[],qn=typeof document<"u",Fn=ha,ca=tn||Xt?"cssFloat":"float",gh=qn&&!fa&&!ha&&"draggable"in document.createElement("div"),ya=function(){if(qn){if(Xt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),ba=function(e,t){var n=ue(e),i=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=Ar(e,0,t),o=Ar(e,1,t),a=s&&ue(s),l=o&&ue(o),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ke(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Ke(o).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(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return o&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=i&&n[ca]==="none"||o&&n[ca]==="none"&&c+u>i)?"vertical":"horizontal"},vh=function(e,t,n){var i=n?e.left:e.top,s=n?e.right:e.bottom,o=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,c=n?t.width:t.height;return i===a||s===l||i+o/2===a+c/2},yh=function(e,t){var n;return jn.some(function(i){var s=i[pt].options.emptyInsertThreshold;if(!(!s||qo(i))){var o=Ke(i),a=e>=o.left-s&&e<=o.right+s,l=t>=o.top-s&&t<=o.bottom+s;if(a&&l)return n=i}}),n},xa=function(e){function t(s,o){return function(a,l,c,u){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(o||d))return!0;if(s==null||s===!1)return!1;if(o&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,c,u),o)(a,l,c,u);var h=(o?a:l).options.group.name;return s===!0||typeof s=="string"&&s===h||s.join&&s.indexOf(h)>-1}}var n={},i=e.group;(!i||Mn(i)!="object")&&(i={name:i}),n.name=i.name,n.checkPull=t(i.pull,!0),n.checkPut=t(i.put),n.revertClone=i.revertClone,e.group=n},wa=function(){!ya&&Ce&&ue(Ce,"display","none")},Ea=function(){!ya&&Ce&&ue(Ce,"display","")};qn&&!fa&&document.addEventListener("click",function(r){if(zn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),zn=!1,!1},!0);var cr=function(e){if(te){e=e.touches?e.touches[0]:e;var t=yh(e.clientX,e.clientY);if(t){var n={};for(var i in e)e.hasOwnProperty(i)&&(n[i]=e[i]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[pt]._onDragOver(n)}}},bh=function(e){te&&te.parentNode[pt]._isOutsideThisEl(e.target)};function ye(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=Pt({},e),r[pt]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(r.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ba(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(o,a){o.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:ye.supportPointer!==!1&&"PointerEvent"in window&&!Xr,emptyInsertThreshold:5};rn.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);xa(e);for(var i in this)i.charAt(0)==="_"&&typeof this[i]=="function"&&(this[i]=this[i].bind(this));this.nativeDraggable=e.forceFallback?!1:gh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?De(r,"pointerdown",this._onTapStart):(De(r,"mousedown",this._onTapStart),De(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(De(r,"dragover",this),De(r,"dragenter",this)),jn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Pt(this,hh())}ye.prototype={constructor:ye,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(wr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,te):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,i=this.options,s=i.preventOnFilter,o=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=i.filter;if(Th(n),!te&&!(/mousedown|pointerdown/.test(o)&&e.button!==0||i.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Xr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Ot(l,i.draggable,n,!1),!(l&&l.animated)&&$n!==l)){if(Sr=ot(l),Qr=ot(l,i.draggable),typeof u=="function"){if(u.call(this,e,l,this)){gt({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),bt("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(d){if(d=Ot(c,d.trim(),n,!1),d)return gt({sortable:t,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),bt("filter",t,{evt:e}),!0}),u)){s&&e.cancelable&&e.preventDefault();return}i.handle&&!Ot(c,i.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var i=this,s=i.el,o=i.options,a=s.ownerDocument,l;if(n&&!te&&n.parentNode===s){var c=Ke(n);if(Ye=s,te=n,tt=te.parentNode,ur=te.nextSibling,$n=n,Dn=o.group,ye.dragged=te,lr={target:te,clientX:(t||e).clientX,clientY:(t||e).clientY},aa=lr.clientX-c.left,la=lr.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,te.style["will-change"]="all",l=function(){if(bt("delayEnded",i,{evt:e}),ye.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents(),!ra&&i.nativeDraggable&&(te.draggable=!0),i._triggerDragStart(e,t),gt({sortable:i,name:"choose",originalEvent:e}),it(te,o.chosenClass,!0)},o.ignore.split(",").forEach(function(u){ma(te,u.trim(),$o)}),De(a,"dragover",cr),De(a,"mousemove",cr),De(a,"touchmove",cr),De(a,"mouseup",i._onDrop),De(a,"touchend",i._onDrop),De(a,"touchcancel",i._onDrop),ra&&this.nativeDraggable&&(this.options.touchStartThreshold=4,te.draggable=!0),bt("delayStart",this,{evt:e}),o.delay&&(!o.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(tn||Xt))){if(ye.eventCanceled){this._onDrop();return}De(a,"mouseup",i._disableDelayedDrag),De(a,"touchend",i._disableDelayedDrag),De(a,"touchcancel",i._disableDelayedDrag),De(a,"mousemove",i._delayedDragTouchMoveHandler),De(a,"touchmove",i._delayedDragTouchMoveHandler),o.supportPointer&&De(a,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(l,o.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(){te&&$o(te),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Te(e,"mouseup",this._disableDelayedDrag),Te(e,"touchend",this._disableDelayedDrag),Te(e,"touchcancel",this._disableDelayedDrag),Te(e,"mousemove",this._delayedDragTouchMoveHandler),Te(e,"touchmove",this._delayedDragTouchMoveHandler),Te(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?De(document,"pointermove",this._onTouchMove):t?De(document,"touchmove",this._onTouchMove):De(document,"mousemove",this._onTouchMove):(De(te,"dragend",this),De(Ye,"dragstart",this._onDragStart));try{document.selection?Bn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Cr=!1,Ye&&te){bt("dragStarted",this,{evt:t}),this.nativeDraggable&&De(document,"dragover",bh);var n=this.options;!e&&it(te,n.dragClass,!1),it(te,n.ghostClass,!0),ye.active=this,e&&this._appendGhost(),gt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Ft){this._lastX=Ft.clientX,this._lastY=Ft.clientY,wa();for(var e=document.elementFromPoint(Ft.clientX,Ft.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Ft.clientX,Ft.clientY),e!==t);)t=e;if(te.parentNode[pt]._isOutsideThisEl(e),t)do{if(t[pt]){var n=void 0;if(n=t[pt]._onDragOver({clientX:Ft.clientX,clientY:Ft.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ea()}},_onTouchMove:function(e){if(lr){var t=this.options,n=t.fallbackTolerance,i=t.fallbackOffset,s=e.touches?e.touches[0]:e,o=Ce&&dr(Ce,!0),a=Ce&&o&&o.a,l=Ce&&o&&o.d,c=Fn&&ft&&oa(ft),u=(s.clientX-lr.clientX+i.x)/(a||1)+(c?c[0]-Mo[0]:0)/(a||1),d=(s.clientY-lr.clientY+i.y)/(l||1)+(c?c[1]-Mo[1]:0)/(l||1);if(!ye.active&&!Cr){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(Ce){o?(o.e+=u-(Oo||0),o.f+=d-(Po||0)):o={a:1,b:0,c:0,d:1,e:u,f:d};var h="matrix(".concat(o.a,",").concat(o.b,",").concat(o.c,",").concat(o.d,",").concat(o.e,",").concat(o.f,")");ue(Ce,"webkitTransform",h),ue(Ce,"mozTransform",h),ue(Ce,"msTransform",h),ue(Ce,"transform",h),Oo=u,Po=d,Ft=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!Ce){var e=this.options.fallbackOnBody?document.body:Ye,t=Ke(te,!0,Fn,!0,e),n=this.options;if(Fn){for(ft=e;ue(ft,"position")==="static"&&ue(ft,"transform")==="none"&&ft!==document;)ft=ft.parentNode;ft!==document.body&&ft!==document.documentElement?(ft===document&&(ft=Nt()),t.top+=ft.scrollTop,t.left+=ft.scrollLeft):ft=Nt(),Mo=oa(ft)}Ce=te.cloneNode(!0),it(Ce,n.ghostClass,!1),it(Ce,n.fallbackClass,!0),it(Ce,n.dragClass,!0),ue(Ce,"transition",""),ue(Ce,"transform",""),ue(Ce,"box-sizing","border-box"),ue(Ce,"margin",0),ue(Ce,"top",t.top),ue(Ce,"left",t.left),ue(Ce,"width",t.width),ue(Ce,"height",t.height),ue(Ce,"opacity","0.8"),ue(Ce,"position",Fn?"absolute":"fixed"),ue(Ce,"zIndex","100000"),ue(Ce,"pointerEvents","none"),ye.ghost=Ce,e.appendChild(Ce),ue(Ce,"transform-origin",aa/parseInt(Ce.style.width)*100+"% "+la/parseInt(Ce.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,i=e.dataTransfer,s=n.options;if(bt("dragStart",this,{evt:e}),ye.eventCanceled){this._onDrop();return}bt("setupClone",this),ye.eventCanceled||(Qe=Go(te),Qe.removeAttribute("id"),Qe.draggable=!1,Qe.style["will-change"]="",this._hideClone(),it(Qe,this.options.chosenClass,!1),ye.clone=Qe),n.cloneId=Bn(function(){bt("clone",n),!ye.eventCanceled&&(n.options.removeCloneOnHide||Ye.insertBefore(Qe,te),n._hideClone(),gt({sortable:n,name:"clone"}))}),!t&&it(te,s.dragClass,!0),t?(zn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Te(document,"mouseup",n._onDrop),Te(document,"touchend",n._onDrop),Te(document,"touchcancel",n._onDrop),i&&(i.effectAllowed="move",s.setData&&s.setData.call(n,i,te)),De(document,"drop",n),ue(te,"transform","translateZ(0)")),Cr=!0,n._dragStartId=Bn(n._dragStarted.bind(n,t,e)),De(document,"selectstart",n),Wr=!0,Xr&&ue(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,i,s,o,a=this.options,l=a.group,c=ye.active,u=Dn===l,d=a.sort,h=ct||c,f,p=this,v=!1;if(zo)return;function y(ie,xe){bt(ie,p,Ut({evt:e,isOwner:u,axis:f?"vertical":"horizontal",revert:o,dragRect:i,targetRect:s,canSort:d,fromSortable:h,target:n,completed:x,onMove:function(Ee,Pe){return Rn(Ye,t,te,i,Ee,Ke(Ee),e,Pe)},changed:T},xe))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ie){return y("dragOverCompleted",{insertion:ie}),ie&&(u?c._hideClone():c._showClone(p),p!==h&&(it(te,ct?ct.options.ghostClass:c.options.ghostClass,!1),it(te,a.ghostClass,!0)),ct!==p&&p!==ye.active?ct=p:p===ye.active&&ct&&(ct=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===te&&!te.animated||n===t&&!n.animated)&&(wr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(te.parentNode[pt]._isOutsideThisEl(e.target),!ie&&cr(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),v=!0}function T(){St=ot(te),rr=ot(te,a.draggable),gt({sortable:p,name:"change",toEl:t,newIndex:St,newDraggableIndex:rr,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Ot(n,a.draggable,t,!0),y("dragOver"),ye.eventCanceled)return v;if(te.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(zn=!1,c&&!a.disabled&&(u?d||(o=tt!==Ye):ct===this||(this.lastPutMode=Dn.checkPull(this,c,te,e))&&l.checkPut(this,c,te,e))){if(f=this._getDirection(e,n)==="vertical",i=Ke(te),y("dragOverValid"),ye.eventCanceled)return v;if(o)return tt=Ye,b(),this._hideClone(),y("revert"),ye.eventCanceled||(ur?Ye.insertBefore(te,ur):Ye.appendChild(te)),x(!0);var E=qo(t,a.draggable);if(!E||Ch(e,f,this)&&!E.animated){if(E===te)return x(!1);if(E&&t===e.target&&(n=E),n&&(s=Ke(n)),Rn(Ye,t,te,i,n,s,e,!!n)!==!1)return b(),E&&E.nextSibling?t.insertBefore(te,E.nextSibling):t.appendChild(te),tt=t,T(),x(!0)}else if(E&&Eh(e,f,this)){var M=Ar(t,0,a,!0);if(M===te)return x(!1);if(n=M,s=Ke(n),Rn(Ye,t,te,i,n,s,e,!1)!==!1)return b(),t.insertBefore(te,M),tt=t,T(),x(!0)}else if(n.parentNode===t){s=Ke(n);var S=0,O,A=te.parentNode!==t,D=!vh(te.animated&&te.toRect||i,n.animated&&n.toRect||s,f),I=f?"top":"left",P=ia(n,"top","top")||ia(te,"top","top"),_=P?P.scrollTop:void 0;wr!==n&&(O=s[I],en=!1,Ln=!D&&a.invertSwap||A),S=Sh(e,n,s,f,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Ln,wr===n);var B;if(S!==0){var H=ot(te);do H-=S,B=tt.children[H];while(B&&(ue(B,"display")==="none"||B===Ce))}if(S===0||B===n)return x(!1);wr=n,Jr=S;var Q=n.nextElementSibling,Y=!1;Y=S===1;var re=Rn(Ye,t,te,i,n,s,e,Y);if(re!==!1)return(re===1||re===-1)&&(Y=re===1),zo=!0,setTimeout(wh,30),b(),Y&&!Q?t.appendChild(te):n.parentNode.insertBefore(te,Y?Q:n),P&&va(P,0,_-P.scrollTop),tt=te.parentNode,O!==void 0&&!Ln&&(_n=Math.abs(O-Ke(n)[I])),T(),x(!0)}if(t.contains(te))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Te(document,"mousemove",this._onTouchMove),Te(document,"touchmove",this._onTouchMove),Te(document,"pointermove",this._onTouchMove),Te(document,"dragover",cr),Te(document,"mousemove",cr),Te(document,"touchmove",cr)},_offUpEvents:function(){var e=this.el.ownerDocument;Te(e,"mouseup",this._onDrop),Te(e,"touchend",this._onDrop),Te(e,"pointerup",this._onDrop),Te(e,"touchcancel",this._onDrop),Te(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(St=ot(te),rr=ot(te,n.draggable),bt("drop",this,{evt:e}),tt=te&&te.parentNode,St=ot(te),rr=ot(te,n.draggable),ye.eventCanceled){this._nulling();return}Cr=!1,Ln=!1,en=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),jo(this.cloneId),jo(this._dragStartId),this.nativeDraggable&&(Te(document,"drop",this),Te(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Xr&&ue(document.body,"user-select",""),ue(te,"transform",""),e&&(Wr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),Ce&&Ce.parentNode&&Ce.parentNode.removeChild(Ce),(Ye===tt||ct&&ct.lastPutMode!=="clone")&&Qe&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),te&&(this.nativeDraggable&&Te(te,"dragend",this),$o(te),te.style["will-change"]="",Wr&&!Cr&&it(te,ct?ct.options.ghostClass:this.options.ghostClass,!1),it(te,this.options.chosenClass,!1),gt({sortable:this,name:"unchoose",toEl:tt,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ye!==tt?(St>=0&&(gt({rootEl:tt,name:"add",toEl:tt,fromEl:Ye,originalEvent:e}),gt({sortable:this,name:"remove",toEl:tt,originalEvent:e}),gt({rootEl:tt,name:"sort",toEl:tt,fromEl:Ye,originalEvent:e}),gt({sortable:this,name:"sort",toEl:tt,originalEvent:e})),ct&&ct.save()):St!==Sr&&St>=0&&(gt({sortable:this,name:"update",toEl:tt,originalEvent:e}),gt({sortable:this,name:"sort",toEl:tt,originalEvent:e})),ye.active&&((St==null||St===-1)&&(St=Sr,rr=Qr),gt({sortable:this,name:"end",toEl:tt,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){bt("nulling",this),Ye=te=tt=Ce=ur=Qe=$n=nr=lr=Ft=Wr=St=rr=Sr=Qr=wr=Jr=ct=Dn=ye.dragged=ye.ghost=ye.clone=ye.active=null,Hn.forEach(function(e){e.checked=!0}),Hn.length=Oo=Po=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":te&&(this._onDragOver(e),xh(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,i=0,s=n.length,o=this.options;i<s;i++)t=n[i],Ot(t,o.draggable,this.el,!1)&&e.push(t.getAttribute(o.dataIdAttr)||kh(t));return e},sort:function(e,t){var n={},i=this.el;this.toArray().forEach(function(s,o){var a=i.children[o];Ot(a,this.options.draggable,i,!1)&&(n[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){n[s]&&(i.removeChild(n[s]),i.appendChild(n[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return Ot(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var i=rn.modifyOption(this,e,t);typeof i<"u"?n[e]=i:n[e]=t,e==="group"&&xa(n)},destroy:function(){bt("destroy",this);var e=this.el;e[pt]=null,Te(e,"mousedown",this._onTapStart),Te(e,"touchstart",this._onTapStart),Te(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Te(e,"dragover",this),Te(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),jn.splice(jn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!nr){if(bt("hideClone",this),ye.eventCanceled)return;ue(Qe,"display","none"),this.options.removeCloneOnHide&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),nr=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(nr){if(bt("showClone",this),ye.eventCanceled)return;te.parentNode==Ye&&!this.options.group.revertClone?Ye.insertBefore(Qe,te):ur?Ye.insertBefore(Qe,ur):Ye.appendChild(Qe),this.options.group.revertClone&&this.animate(te,Qe),ue(Qe,"display",""),nr=!1}}};function xh(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function Rn(r,e,t,n,i,s,o,a){var l,c=r[pt],u=c.options.onMove,d;return window.CustomEvent&&!Xt&&!tn?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=r,l.dragged=t,l.draggedRect=n,l.related=i||e,l.relatedRect=s||Ke(e),l.willInsertAfter=a,l.originalEvent=o,r.dispatchEvent(l),u&&(d=u.call(c,l,o)),d}function $o(r){r.draggable=!1}function wh(){zo=!1}function Eh(r,e,t){var n=Ke(Ar(t.el,0,t.options,!0)),i=10;return e?r.clientX<n.left-i||r.clientY<n.top&&r.clientX<n.right:r.clientY<n.top-i||r.clientY<n.bottom&&r.clientX<n.left}function Ch(r,e,t){var n=Ke(qo(t.el,t.options.draggable)),i=10;return e?r.clientX>n.right+i||r.clientX<=n.right&&r.clientY>n.bottom&&r.clientX>=n.left:r.clientX>n.right&&r.clientY>n.top||r.clientX<=n.right&&r.clientY>n.bottom+i}function Sh(r,e,t,n,i,s,o,a){var l=n?r.clientY:r.clientX,c=n?t.height:t.width,u=n?t.top:t.left,d=n?t.bottom:t.right,h=!1;if(!o){if(a&&_n<c*i){if(!en&&(Jr===1?l>u+c*s/2:l<d-c*s/2)&&(en=!0),en)h=!0;else if(Jr===1?l<u+_n:l>d-_n)return-Jr}else if(l>u+c*(1-i)/2&&l<d-c*(1-i)/2)return Ah(e)}return h=h||o,h&&(l<u+c*s/2||l>d-c*s/2)?l>u+c/2?1:-1:0}function Ah(r){return ot(te)<ot(r)?1:-1}function kh(r){for(var e=r.tagName+r.className+r.src+r.href+r.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function Th(r){Hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&Hn.push(n)}}function Bn(r){return setTimeout(r,0)}function jo(r){return clearTimeout(r)}qn&&De(document,"touchmove",function(r){(ye.active||Cr)&&r.cancelable&&r.preventDefault()});ye.utils={on:De,off:Te,css:ue,find:ma,is:function(e,t){return!!Ot(e,t,e,!1)},extend:uh,throttle:ga,closest:Ot,toggleClass:it,clone:Go,index:ot,nextTick:Bn,cancelNextTick:jo,detectDirection:ba,getChild:Ar};ye.get=function(r){return r[pt]};ye.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;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&&(ye.utils=Ut(Ut({},ye.utils),n.utils)),rn.mount(n)})};ye.create=function(r,e){return new ye(r,e)};ye.version=ah;var nt=[],Yr,Ho,Vo=!1,_o,Bo,Vn,Kr;function Ih(){function r(){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 r.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?De(document,"dragover",this._handleAutoScroll):this.options.supportPointer?De(document,"pointermove",this._handleFallbackAutoScroll):n.touches?De(document,"touchmove",this._handleFallbackAutoScroll):De(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Te(document,"dragover",this._handleAutoScroll):(Te(document,"pointermove",this._handleFallbackAutoScroll),Te(document,"touchmove",this._handleFallbackAutoScroll),Te(document,"mousemove",this._handleFallbackAutoScroll)),ua(),Nn(),dh()},nulling:function(){Vn=Ho=Yr=Vo=Kr=_o=Bo=null,nt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var i=this,s=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(s,o);if(Vn=t,n||this.options.forceAutoScrollFallback||tn||Xt||Xr){No(t,this.options,a,n);var l=ir(a,!0);Vo&&(!Kr||s!==_o||o!==Bo)&&(Kr&&ua(),Kr=setInterval(function(){var c=ir(document.elementFromPoint(s,o),!0);c!==l&&(l=c,Nn()),No(t,i.options,c,n)},10),_o=s,Bo=o)}else{if(!this.options.bubbleScroll||ir(a,!0)===Nt()){Nn();return}No(t,this.options,ir(a,!1),!1)}}},Pt(r,{pluginName:"scroll",initializeByDefault:!0})}function Nn(){nt.forEach(function(r){clearInterval(r.pid)}),nt=[]}function ua(){clearInterval(Kr)}var No=ga(function(r,e,t,n){if(e.scroll){var i=(r.touches?r.touches[0]:r).clientX,s=(r.touches?r.touches[0]:r).clientY,o=e.scrollSensitivity,a=e.scrollSpeed,l=Nt(),c=!1,u;Ho!==t&&(Ho=t,Nn(),Yr=e.scroll,u=e.scrollFn,Yr===!0&&(Yr=ir(t,!0)));var d=0,h=Yr;do{var f=h,p=Ke(f),v=p.top,y=p.bottom,b=p.left,x=p.right,T=p.width,E=p.height,M=void 0,S=void 0,O=f.scrollWidth,A=f.scrollHeight,D=ue(f),I=f.scrollLeft,P=f.scrollTop;f===l?(M=T<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),S=E<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=T<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),S=E<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var _=M&&(Math.abs(x-i)<=o&&I+T<O)-(Math.abs(b-i)<=o&&!!I),B=S&&(Math.abs(y-s)<=o&&P+E<A)-(Math.abs(v-s)<=o&&!!P);if(!nt[d])for(var H=0;H<=d;H++)nt[H]||(nt[H]={});(nt[d].vx!=_||nt[d].vy!=B||nt[d].el!==f)&&(nt[d].el=f,nt[d].vx=_,nt[d].vy=B,clearInterval(nt[d].pid),(_!=0||B!=0)&&(c=!0,nt[d].pid=setInterval(function(){n&&this.layer===0&&ye.active._onTouchMove(Vn);var Q=nt[this.layer].vy?nt[this.layer].vy*a:0,Y=nt[this.layer].vx?nt[this.layer].vx*a:0;typeof u=="function"&&u.call(ye.dragged.parentNode[pt],Y,Q,r,Vn,nt[this.layer].el)!=="continue"||va(nt[this.layer].el,Y,Q)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&h!==l&&(h=ir(h,!1)));Vo=c}},30),Ca=function(e){var t=e.originalEvent,n=e.putSortable,i=e.dragEl,s=e.activeSortable,o=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=n||s;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,d=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(d)&&(o("spill"),this.onSpill({dragEl:i,putSortable:n}))}};function Wo(){}Wo.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 i=Ar(this.sortable.el,this.startIndex,this.options);i?this.sortable.el.insertBefore(t,i):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:Ca};Pt(Wo,{pluginName:"revertOnSpill"});function Yo(){}Yo.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,i=n||this.sortable;i.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),i.animateAll()},drop:Ca};Pt(Yo,{pluginName:"removeOnSpill"});var we=[],Ct=[],Hr,Rt,Vr=!1,xt=!1,Er=!1,Ve,qr,On;function Sa(){function r(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?De(document,"pointerup",this._deselectMultiDrag):(De(document,"mouseup",this._deselectMultiDrag),De(document,"touchend",this._deselectMultiDrag))),De(document,"keydown",this._checkKeyDown),De(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(i,s){var o="";we.length&&Rt===e?we.forEach(function(a,l){o+=(l?", ":"")+a.textContent}):o=s.textContent,i.setData("Text",o)}}}return r.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var n=t.dragEl;Ve=n},delayEnded:function(){this.isMultiDrag=~we.indexOf(Ve)},setupClone:function(t){var n=t.sortable,i=t.cancel;if(this.isMultiDrag){for(var s=0;s<we.length;s++)Ct.push(Go(we[s])),Ct[s].sortableIndex=we[s].sortableIndex,Ct[s].draggable=!1,Ct[s].style["will-change"]="",it(Ct[s],this.options.selectedClass,!1),we[s]===Ve&&it(Ct[s],this.options.chosenClass,!1);n._hideClone(),i()}},clone:function(t){var n=t.sortable,i=t.rootEl,s=t.dispatchSortableEvent,o=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||we.length&&Rt===n&&(da(!0,i),s("clone"),o()))},showClone:function(t){var n=t.cloneNowShown,i=t.rootEl,s=t.cancel;this.isMultiDrag&&(da(!1,i),Ct.forEach(function(o){ue(o,"display","")}),n(),On=!1,s())},hideClone:function(t){var n=this,i=t.sortable,s=t.cloneNowHidden,o=t.cancel;this.isMultiDrag&&(Ct.forEach(function(a){ue(a,"display","none"),n.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),On=!0,o())},dragStartGlobal:function(t){var n=t.sortable;!this.isMultiDrag&&Rt&&Rt.multiDrag._deselectMultiDrag(),we.forEach(function(i){i.sortableIndex=ot(i)}),we=we.sort(function(i,s){return i.sortableIndex-s.sortableIndex}),Er=!0},dragStarted:function(t){var n=this,i=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(i.captureAnimationState(),this.options.animation)){we.forEach(function(o){o!==Ve&&ue(o,"position","absolute")});var s=Ke(Ve,!1,!0,!0);we.forEach(function(o){o!==Ve&&sa(o,s)}),xt=!0,Vr=!0}i.animateAll(function(){xt=!1,Vr=!1,n.options.animation&&we.forEach(function(o){Fo(o)}),n.options.sort&&Pn()})}},dragOver:function(t){var n=t.target,i=t.completed,s=t.cancel;xt&&~we.indexOf(n)&&(i(!1),s())},revert:function(t){var n=t.fromSortable,i=t.rootEl,s=t.sortable,o=t.dragRect;we.length>1&&(we.forEach(function(a){s.addAnimationState({target:a,rect:xt?Ke(a):o}),Fo(a),a.fromRect=o,n.removeAnimationState(a)}),xt=!1,Dh(!this.options.removeCloneOnHide,i))},dragOverCompleted:function(t){var n=t.sortable,i=t.isOwner,s=t.insertion,o=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(s){if(i&&o._hideClone(),Vr=!1,c.animation&&we.length>1&&(xt||!i&&!o.options.sort&&!l)){var u=Ke(Ve,!1,!0,!0);we.forEach(function(h){h!==Ve&&(sa(h,u),a.appendChild(h))}),xt=!0}if(!i)if(xt||Pn(),we.length>1){var d=On;o._showClone(n),o.options.animation&&!On&&d&&Ct.forEach(function(h){o.addAnimationState({target:h,rect:qr}),h.fromRect=qr,h.thisAnimationDuration=null})}else o._showClone(n)}},dragOverAnimationCapture:function(t){var n=t.dragRect,i=t.isOwner,s=t.activeSortable;if(we.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!i&&s.multiDrag.isMultiDrag){qr=Pt({},n);var o=dr(Ve,!0);qr.top-=o.f,qr.left-=o.e}},dragOverAnimationComplete:function(){xt&&(xt=!1,Pn())},drop:function(t){var n=t.originalEvent,i=t.rootEl,s=t.parentEl,o=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(n){var d=this.options,h=s.children;if(!Er)if(d.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),it(Ve,d.selectedClass,!~we.indexOf(Ve)),~we.indexOf(Ve))we.splice(we.indexOf(Ve),1),Hr=null,Gr({sortable:o,rootEl:i,name:"deselect",targetEl:Ve,originalEvent:n});else{if(we.push(Ve),Gr({sortable:o,rootEl:i,name:"select",targetEl:Ve,originalEvent:n}),n.shiftKey&&Hr&&o.el.contains(Hr)){var f=ot(Hr),p=ot(Ve);if(~f&&~p&&f!==p){var v,y;for(p>f?(y=f,v=p):(y=p,v=f+1);y<v;y++)~we.indexOf(h[y])||(it(h[y],d.selectedClass,!0),we.push(h[y]),Gr({sortable:o,rootEl:i,name:"select",targetEl:h[y],originalEvent:n}))}}else Hr=Ve;Rt=u}if(Er&&this.isMultiDrag){if(xt=!1,(s[pt].options.sort||s!==i)&&we.length>1){var b=Ke(Ve),x=ot(Ve,":not(."+this.options.selectedClass+")");if(!Vr&&d.animation&&(Ve.thisAnimationDuration=null),u.captureAnimationState(),!Vr&&(d.animation&&(Ve.fromRect=b,we.forEach(function(E){if(E.thisAnimationDuration=null,E!==Ve){var M=xt?Ke(E):b;E.fromRect=M,u.addAnimationState({target:E,rect:M})}})),Pn(),we.forEach(function(E){h[x]?s.insertBefore(E,h[x]):s.appendChild(E),x++}),l===ot(Ve))){var T=!1;we.forEach(function(E){if(E.sortableIndex!==ot(E)){T=!0;return}}),T&&a("update")}we.forEach(function(E){Fo(E)}),u.animateAll()}Rt=u}(i===s||c&&c.lastPutMode!=="clone")&&Ct.forEach(function(E){E.parentNode&&E.parentNode.removeChild(E)})}},nullingGlobal:function(){this.isMultiDrag=Er=!1,Ct.length=0},destroyGlobal:function(){this._deselectMultiDrag(),Te(document,"pointerup",this._deselectMultiDrag),Te(document,"mouseup",this._deselectMultiDrag),Te(document,"touchend",this._deselectMultiDrag),Te(document,"keydown",this._checkKeyDown),Te(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof Er<"u"&&Er)&&Rt===this.sortable&&!(t&&Ot(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;we.length;){var n=we[0];it(n,this.options.selectedClass,!1),we.shift(),Gr({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)}},Pt(r,{pluginName:"multiDrag",utils:{select:function(t){var n=t.parentNode[pt];!n||!n.options.multiDrag||~we.indexOf(t)||(Rt&&Rt!==n&&(Rt.multiDrag._deselectMultiDrag(),Rt=n),it(t,n.options.selectedClass,!0),we.push(t))},deselect:function(t){var n=t.parentNode[pt],i=we.indexOf(t);!n||!n.options.multiDrag||!~i||(it(t,n.options.selectedClass,!1),we.splice(i,1))}},eventProperties:function(){var t=this,n=[],i=[];return we.forEach(function(s){n.push({multiDragElement:s,index:s.sortableIndex});var o;xt&&s!==Ve?o=-1:xt?o=ot(s,":not(."+t.options.selectedClass+")"):o=ot(s),i.push({multiDragElement:s,index:o})}),{items:rh(we),clones:[].concat(Ct),oldIndicies:n,newIndicies:i}},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 Dh(r,e){we.forEach(function(t,n){var i=e.children[t.sortableIndex+(r?Number(n):0)];i?e.insertBefore(t,i):e.appendChild(t)})}function da(r,e){Ct.forEach(function(t,n){var i=e.children[t.sortableIndex+(r?Number(n):0)];i?e.insertBefore(t,i):e.appendChild(t)})}function Pn(){we.forEach(function(r){r!==Ve&&r.parentNode&&r.parentNode.removeChild(r)})}ye.mount(new Ih);ye.mount(Yo,Wo);var hr=ye;var Aa={name:function(r,e){let t=r.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created:function(r,e){let t=Number(r.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated:function(r,e){let t=Number(r.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},ka={up:{active(r,e,t){return!(r.previousElementSibling===null&&!e)},run(r,e,t){(r.previousElementSibling||e).insertAdjacentElement("beforebegin",r)}},down:{active(r,e,t){return!(r.nextElementSibling===null&&!e)},run(r,e,t){(r.nextElementSibling||e).insertAdjacentElement("afterend",r)}},next_book:{active(r,e,t){return t.nextElementSibling!==null},run(r,e,t){t.nextElementSibling.querySelector("ul").prepend(r)}},prev_book:{active(r,e,t){return t.previousElementSibling!==null},run(r,e,t){t.previousElementSibling.querySelector("ul").appendChild(r)}},next_chapter:{active(r,e,t){return r.dataset.type==="page"&&this.getNextChapter(r,e)},run(r,e,t){this.getNextChapter(r,e).querySelector("ul").prepend(r)},getNextChapter(r,e){let t=e||r,n=Array.from(t.parentElement.children),i=n.indexOf(t);return n.slice(i+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(r,e,t){return r.dataset.type==="page"&&this.getPrevChapter(r,e)},run(r,e,t){this.getPrevChapter(r,e).querySelector("ul").append(r)},getPrevChapter(r,e){let t=e||r,n=Array.from(t.parentElement.children),i=n.indexOf(t);return n.slice(0,i).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(r,e,t){return e||e===null&&r.nextElementSibling},run(r,e,t){t.querySelector("ul").append(r)}},book_start:{active(r,e,t){return e||e===null&&r.previousElementSibling},run(r,e,t){t.querySelector("ul").prepend(r)}},before_chapter:{active(r,e,t){return e},run(r,e,t){e.insertAdjacentElement("beforebegin",r)}},after_chapter:{active(r,e,t){return e},run(r,e,t){e.insertAdjacentElement("afterend",r)}}},Gn=class extends V{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,hr.mount(new Sa);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",i=>{let s=i.target.closest(".sort-box-options [data-sort]");if(!s)return;i.preventDefault();let o=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");t=e===a?!t:!1;let l=Aa[a];t&&n.includes(a)&&(l=function(c,u){return 0-Aa[a](c,u)});for(let c of o)Array.from(c.children).filter(d=>d.matches("li")).sort(l).forEach(d=>{c.appendChild(d)});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(i=>{let s=tr(i.data);this.sortContainer.append(s),this.setupBookSortable(s),this.updateMoveActionStateForAll(),s.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"]},i={name:"chapter",pull:["book","chapter"],put:function(s,o,a){return a.getAttribute("data-type")==="page"}};for(let s of t)hr.create(s,{group:s.classList.contains("sort-list")?n:i,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:o=>{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 i=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(o=>o.matches('[data-type="page"], [data-type="chapter"]'));for(let o=0;o<s.length;o++)this.addBookChildToMap(s[o],o,i,e)}return e}addBookChildToMap(e,t,n,i){let s=e.getAttribute("data-type"),o=!1,a=e.getAttribute("data-id");i.push({id:a,sort:t,parentChapter:o,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)i.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]"),i=e.parentElement.closest('[data-type="book"]');ka[t].run(e,n,i),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[i,s]of Object.entries(ka)){let o=e.querySelector(`[data-move="${i}"]`);o.disabled=!s.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 Wn=new WeakMap;function Ta(r,e=400,t=null){on(r),r.style.display="block",nn(r,{opacity:["0","1"]},e,()=>{t&&t()})}function Yn(r,e=400,t=null){on(r),nn(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function kr(r,e=400){on(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),i=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),o={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[i,"0px"],paddingBottom:[s,"0px"]};nn(r,o,e,()=>{r.style.display="none"})}function Tr(r,e=400){on(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),i=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),o={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",i],paddingBottom:["0px",s]};nn(r,o,e)}function Ia(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),i=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{on(r);let o=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${o}px`],overflow:["hidden","hidden"],paddingTop:[i,l],paddingBottom:[s,c]};nn(r,u,e)}}function nn(r,e,t=400,n=null){let i=Object.keys(e);for(let o of i)r.style[o]=e[o][0];let s=()=>{for(let o of i)r.style[o]=null;r.style.transition=null,r.removeEventListener("transitionend",s),Wn.delete(r),n&&n()};setTimeout(()=>{r.style.transition=`all ease-in-out ${t}ms`;for(let o of i)r.style[o]=e[o][1];r.addEventListener("transitionend",s),Wn.set(r,s)},15)}function on(r){Wn.has(r)&&Wn.get(r)()}var Kn=class extends V{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"),Tr(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),kr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Xn=class extends V{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.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),je(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),xn(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),je(this.saveButton,e=>this.save()),Ge(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let t=e.dataset.lang,n=this.favourites.has(t);e.setAttribute("data-favourite",n?"true":"false"),Ge(e.parentElement,".lang-option-favorite-toggle","click",()=>{n=!n,n?this.favourites.add(t):this.favourites.delete(t),e.setAttribute("data-favourite",n?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:t,active:n}),this.sortLanguageList(),n&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((t,n)=>{let i=t.dataset.favourite==="true",s=n.dataset.favourite==="true";return i&&!s?-1:s&&!i||t.dataset.lang>n.dataset.lang?1:-1}).map(t=>t.parentElement);for(let t of e)this.languageOptionsContainer.append(t)}save(){this.callback&&this.callback(this.editor.getValue(),this.languageInput.value),this.hide()}open(e,t,n){this.languageInput.value=t,this.callback=n,this.show().then(()=>this.languageInputChange(t)).then(()=>window.importVersioned("code")).then(i=>i.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase();for(let n of this.languageButtons){let i=n.dataset.lang.toLowerCase().trim(),s=t===i;n.classList.toggle("active",s),s&&n.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}};var Zn=class extends V{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var Qn=class extends V{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Jn=class extends V{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"),Tr(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),kr(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var ei=class extends V{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,je(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var ti=class extends V{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 ri=class extends V{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 sn,Ko,an,Xo,Ir=class{constructor(e,t=null,n=null){xo(this,sn);xo(this,an);this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",_r(this,sn,Ko).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",_r(this,sn,Ko).bind(this))}focusNext(){let e=_r(this,an,Xo).call(this),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=_r(this,an,Xo).call(this),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}};sn=new WeakSet,Ko=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))},an=new WeakSet,Xo=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 ni=class extends V{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,i=this.toggle.getBoundingClientRect().height,s=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`,n=s?window.innerHeight-t.top-i/2:t.top),s?(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 o=this.menu.querySelector("input");o!==null&&o.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 Ir(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()}),je(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var ii=class extends V{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=Bt(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 i=!e||n.textContent.toLowerCase().includes(e);n.style.display=i?"flex":"none",n.classList.toggle("hidden",!i)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=Ia(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 La=gn(Da());var si=class extends V{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new La.default(this.container,{addRemoveLinks:!0,dictRemoveFile:this.removeMessage,timeout:Number(window.uploadTimeout)||6e4,maxFilesize:this.uploadLimit,url:this.url,withCredentials:!0,init(){this.dz=this,this.dz.on("sending",e.onSending.bind(e)),this.dz.on("success",e.onSuccess.bind(e)),this.dz.on("error",e.onError.bind(e))}})}onSending(e,t,n){let i=window.document.querySelector("meta[name=token]").getAttribute("content");n.append("_token",i),t.ontimeout=s=>{this.dz.emit("complete",e),this.dz.emit("error",e,this.timeoutMessage)}}onSuccess(e,t){this.$emit("success",{file:e,data:t}),this.successMessage&&window.$events.emit("success",this.successMessage),Yn(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let i=s=>{let o=e.previewElement.querySelector("[data-dz-errormessage]");o.textContent=s};n&&n.status===413?i(this.uploadLimitMessage):t.file&&i(t.file)}removeAll(){this.dz.removeAllFiles(!0)}};var ai=class extends V{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 li=class extends V{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 i of n)i.disabled=t,i.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",e=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}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}`),i=tr(n.data);this.roleContainer.append(i),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),n=e.dataset.roleId,i=e.dataset.roleName,s=document.createElement("option");s.value=n,s.textContent=i,this.roleSelect.append(s),t.remove()}};var ci=class extends V{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()}),je(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();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 ui=class extends V{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",t=>{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()}),Ge(this.$el,"[data-entity-type]","keydown",(t,n)=>{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]")),n=t.indexOf(document.activeElement),i=t[n+(e?1:-1)]||t[0];i&&i.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"),i=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${i}`:"";let o=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(i),name:a,link:o};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&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 di=class extends V{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 hi=class extends V{setup(){this.container=this.$el,this.name=this.$opts.name,je(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var fi=class extends V{setup(e){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){Tr(e,200)}close(e){kr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var pi=class extends V{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=Bt(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let t=this.input.value;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 Ir(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=tr(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 mi=class extends V{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 gi=class extends V{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.formContainer=this.$refs.formContainer,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(){je(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()}),je(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),Ge(this.listContainer,".load-more","click",async e=>{zr(e.target),this.page++,await this.loadGallery(),e.target.remove()}),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",e=>{e.target.src=baseUrl("loading_error.png")},!0),je(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),Ge(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),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),Qs(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e,window.$components.init(t);for(let n of[...t.children])this.listContainer.appendChild(n)}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=""}resetEditForm(){this.formContainer.innerHTML=""}resetListView(){zr(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,i=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),i?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",i),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:i}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=i,window.$components.init(this.formContainer)}};var vi=class extends V{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 yi=class extends V{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 ju=gn($u()),Hu=gn(zu()),Oi=class{constructor(){this.renderer=new ju.default({html:!0}),this.renderer.use(Hu.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Jp(r,e){return document.createElement(r,e)}function em(r,e,t){return document.createElementNS(r,e,t)}function tm(){return mr(document.createDocumentFragment())}function rm(r){return document.createTextNode(r)}function nm(r){return document.createComment(r)}function im(r,e,t){if(Zt(r)){let n=r;for(;n&&Zt(n);)n=mr(n).parent;r=n??r}Zt(e)&&(e=mr(e,r)),t&&Zt(t)&&(t=mr(t).firstChildNode),r.insertBefore(e,t)}function om(r,e){r.removeChild(e)}function sm(r,e){Zt(e)&&(e=mr(e,r)),r.appendChild(e)}function Vu(r){if(Zt(r)){for(;r&&Zt(r);)r=mr(r).parent;return r??null}return r.parentNode}function am(r){var e;if(Zt(r)){let t=mr(r),n=Vu(t);if(n&&t.lastChildNode){let i=Array.from(n.childNodes),s=i.indexOf(t.lastChildNode);return(e=i[s+1])!==null&&e!==void 0?e:null}return null}return r.nextSibling}function lm(r){return r.tagName}function cm(r,e){r.textContent=e}function um(r){return r.textContent}function dm(r){return r.nodeType===1}function hm(r){return r.nodeType===3}function fm(r){return r.nodeType===8}function Zt(r){return r.nodeType===11}function mr(r,e){var t,n,i;let s=r;return(t=s.parent)!==null&&t!==void 0||(s.parent=e??null),(n=s.firstChildNode)!==null&&n!==void 0||(s.firstChildNode=r.firstChild),(i=s.lastChildNode)!==null&&i!==void 0||(s.lastChildNode=r.lastChild),s}var Pi={createElement:Jp,createElementNS:em,createTextNode:rm,createDocumentFragment:tm,createComment:nm,insertBefore:im,removeChild:om,appendChild:sm,parentNode:Vu,nextSibling:am,tagName:lm,setTextContent:cm,getTextContent:um,isElement:dm,isText:hm,isComment:fm,isDocumentFragment:Zt};function Qt(r,e,t,n,i){let s=e===void 0?void 0:e.key;return{sel:r,data:e,children:t,text:n,elm:i,key:s}}var qu=Array.isArray;function Gu(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function Is(r){return r===void 0}function wt(r){return r!==void 0}var Ds=Qt("",{},[],void 0,void 0);function hn(r,e){var t,n;let i=r.key===e.key,s=((t=r.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is),o=r.sel===e.sel,a=!r.sel&&r.sel===e.sel?typeof r.text==typeof e.text:!0;return o&&i&&s&&a}function mm(){throw new Error("The document fragment is not supported on this platform.")}function gm(r,e){return r.isElement(e)}function vm(r,e){return r.isDocumentFragment(e)}function ym(r,e,t){var n;let i={};for(let s=e;s<=t;++s){let o=(n=r[s])===null||n===void 0?void 0:n.key;o!==void 0&&(i[o]=s)}return i}var bm=["create","update","remove","destroy","pre","post"];function Ls(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},i=e!==void 0?e:Pi;for(let p of bm)for(let v of r){let y=v[p];y!==void 0&&n[p].push(y)}function s(p){let v=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return Qt(i.tagName(p).toLowerCase()+v+b,{},[],void 0,p)}function o(p){return Qt(void 0,{},[],void 0,p)}function a(p,v){return function(){if(--v===0){let b=i.parentNode(p);i.removeChild(b,p)}}}function l(p,v){var y,b,x,T;let E,M=p.data;if(M!==void 0){let A=(y=M.hook)===null||y===void 0?void 0:y.init;wt(A)&&(A(p),M=p.data)}let S=p.children,O=p.sel;if(O==="!")Is(p.text)&&(p.text=""),p.elm=i.createComment(p.text);else if(O!==void 0){let A=O.indexOf("#"),D=O.indexOf(".",A),I=A>0?A:O.length,P=D>0?D:O.length,_=A!==-1||D!==-1?O.slice(0,Math.min(I,P)):O,B=p.elm=wt(M)&&wt(E=M.ns)?i.createElementNS(E,_,M):i.createElement(_,M);for(I<P&&B.setAttribute("id",O.slice(I+1,P)),D>0&&B.setAttribute("class",O.slice(P+1).replace(/\./g," ")),E=0;E<n.create.length;++E)n.create[E](Ds,p);if(qu(S))for(E=0;E<S.length;++E){let Q=S[E];Q!=null&&i.appendChild(B,l(Q,v))}else Gu(p.text)&&i.appendChild(B,i.createTextNode(p.text));let H=p.data.hook;wt(H)&&((b=H.create)===null||b===void 0||b.call(H,Ds,p),H.insert&&v.push(p))}else if(!((x=t?.experimental)===null||x===void 0)&&x.fragments&&p.children){for(p.elm=((T=i.createDocumentFragment)!==null&&T!==void 0?T:mm)(),E=0;E<n.create.length;++E)n.create[E](Ds,p);for(E=0;E<p.children.length;++E){let A=p.children[E];A!=null&&i.appendChild(p.elm,l(A,v))}}else p.elm=i.createTextNode(p.text);return p.elm}function c(p,v,y,b,x,T){for(;b<=x;++b){let E=y[b];E!=null&&i.insertBefore(p,l(E,T),v)}}function u(p){var v,y;let b=p.data;if(b!==void 0){(y=(v=b?.hook)===null||v===void 0?void 0:v.destroy)===null||y===void 0||y.call(v,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let T=p.children[x];T!=null&&typeof T!="string"&&u(T)}}}function d(p,v,y,b){for(var x,T;y<=b;++y){let E,M,S=v[y];if(S!=null)if(wt(S.sel)){u(S),E=n.remove.length+1,M=a(S.elm,E);for(let A=0;A<n.remove.length;++A)n.remove[A](S,M);let O=(T=(x=S?.data)===null||x===void 0?void 0:x.hook)===null||T===void 0?void 0:T.remove;wt(O)?O(S,M):M()}else S.children?(u(S),d(p,S.children,0,S.children.length-1)):i.removeChild(p,S.elm)}}function h(p,v,y,b){let x=0,T=0,E=v.length-1,M=v[0],S=v[E],O=y.length-1,A=y[0],D=y[O],I,P,_,B;for(;x<=E&&T<=O;)M==null?M=v[++x]:S==null?S=v[--E]:A==null?A=y[++T]:D==null?D=y[--O]:hn(M,A)?(f(M,A,b),M=v[++x],A=y[++T]):hn(S,D)?(f(S,D,b),S=v[--E],D=y[--O]):hn(M,D)?(f(M,D,b),i.insertBefore(p,M.elm,i.nextSibling(S.elm)),M=v[++x],D=y[--O]):hn(S,A)?(f(S,A,b),i.insertBefore(p,S.elm,M.elm),S=v[--E],A=y[++T]):(I===void 0&&(I=ym(v,x,E)),P=I[A.key],Is(P)?i.insertBefore(p,l(A,b),M.elm):(_=v[P],_.sel!==A.sel?i.insertBefore(p,l(A,b),M.elm):(f(_,A,b),v[P]=void 0,i.insertBefore(p,_.elm,M.elm))),A=y[++T]);T<=O&&(B=y[O+1]==null?null:y[O+1].elm,c(p,B,y,T,O,b)),x<=E&&d(p,v,x,E)}function f(p,v,y){var b,x,T,E,M,S,O,A;let D=(b=v.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,v);let I=v.elm=p.elm;if(p===v)return;if(v.data!==void 0||wt(v.text)&&v.text!==p.text){(T=v.data)!==null&&T!==void 0||(v.data={}),(E=p.data)!==null&&E!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,v);(O=(S=(M=v.data)===null||M===void 0?void 0:M.hook)===null||S===void 0?void 0:S.update)===null||O===void 0||O.call(S,p,v)}let P=p.children,_=v.children;Is(v.text)?wt(P)&&wt(_)?P!==_&&h(I,P,_,y):wt(_)?(wt(p.text)&&i.setTextContent(I,""),c(I,null,_,0,_.length-1,y)):wt(P)?d(I,P,0,P.length-1):wt(p.text)&&i.setTextContent(I,""):p.text!==v.text&&(wt(P)&&d(I,P,0,P.length-1),i.setTextContent(I,v.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,v)}return function(v,y){let b,x,T,E=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(gm(i,v)?v=s(v):vm(i,v)&&(v=o(v)),hn(v,y)?f(v,y,E):(x=v.elm,T=i.parentNode(x),l(y,E),T!==null&&(i.insertBefore(T,y.elm,i.nextSibling(x)),d(T,[v],0,0))),b=0;b<E.length;++b)E[b].data.hook.insert(E[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function Fs(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let i=e[n];if(typeof i=="string")continue;let s=i.data;s!==void 0&&Fs(s,i.children,i.sel)}}function fn(r,e){let t=e!==void 0?e:Pi,n;if(t.isElement(r)){let i=r.id?"#"+r.id:"",s=r.getAttribute("class"),o=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+i+o,l={},c={},u={},d=[],h,f,p,v=r.attributes,y=r.childNodes;for(f=0,p=v.length;f<p;f++)h=v[f].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?c[h.slice(5)]=v[f].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=v[f].nodeValue);for(f=0,p=y.length;f<p;f++)d.push(fn(y[f],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]==="#")&&Fs(u,d,a),Qt(a,u,d,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),Qt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),Qt("!",{},[],n,r)):Qt("",{},[],void 0,r)}var xm="http://www.w3.org/1999/xlink",wm="http://www.w3.org/XML/1998/namespace";function Wu(r,e){let t,n=e.elm,i=r.data.attrs,s=e.data.attrs;if(!(!i&&!s)&&i!==s){i=i||{},s=s||{};for(t in s){let o=s[t];i[t]!==o&&(o===!0?n.setAttribute(t,""):o===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,o):t.charCodeAt(3)===58?n.setAttributeNS(wm,t,o):t.charCodeAt(5)===58?n.setAttributeNS(xm,t,o):n.setAttribute(t,o))}for(t in i)t in s||n.removeAttribute(t)}}var Rs={create:Wu,update:Wu};var Mi;function Em(){return Mi||(Mi=Ls([Rs]),Mi)}function Yu(r,e){let t=document.createElement("div");t.innerHTML=e,Em()(fn(r),fn(t))}var $i=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 i=e.target.closest("[drawio-diagram]");if(i!==null&&t){this.editor.actions.editDrawing(i);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 t=this.doc.body;if(t.children.length===0){let i=document.createElement("div");this.doc.body.append(i)}let n=t.children[0];Yu(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 Vt=null,Ms,Os,Ps;function Cm(r,e,t){Os=e,Ps=t,Vt=document.createElement("iframe"),Vt.setAttribute("frameborder","0"),window.addEventListener("message",Xu),Vt.setAttribute("src",r),Vt.setAttribute("class","fullscreen"),Vt.style.backgroundColor="#FFFFFF",document.body.appendChild(Vt),Ms=new URL(r).origin}function Ku(){Zu()}function Xu(r){if(!r.data||r.data.length<1||r.origin!==Ms)return;let e=JSON.parse(r.data);e.event==="init"?km():e.event==="exit"?Zu():e.event==="save"?Am(e):e.event==="export"?Sm(e):e.event==="configure"&&Tm()}function Sm(r){Ps&&Ps(r.data)}function Am(r){$s({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function km(){Os&&Os().then(r=>{$s({action:"load",autosave:1,xml:r})})}function Tm(){let r={};window.$events.emitPublic(Vt,"editor-drawio::configure",{config:r}),$s({action:"configure",config:r})}function Zu(){window.removeEventListener("message",Xu),Vt&&document.body.removeChild(Vt)}function $s(r){Vt.contentWindow.postMessage(JSON.stringify(r),Ms)}async function Im(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function Dm(r){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),Ku(),e}}var kt={show:Cm,close:Ku,upload:Im,load:Dm};var _i=class{constructor(e){this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=this.editor.cm.getValue();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}insertImage(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{let i=n.thumbs.display||n.url,o="[]("+n.url+")";this.editor.cm.focus(),this.editor.cm.replaceSelection(o),this.editor.cm.setCursor(e.line,e.ch+o.length)},"gallery")}insertLink(){let e=this.editor.cm.getCursor("from"),t=this.editor.cm.getSelection()||"",n=`[${t}]()`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n);let i=t===""?-3:-1;this.editor.cm.setCursor(e.line,e.ch+n.length+i)}showImageManager(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{this.insertDrawing(n,e)},"drawio")}showLinkSelector(){let e=this.editor.cm.getCursor("from");window.$components.first("entity-selector-popup").show(n=>{let s=`[${this.editor.cm.getSelection()||n.name}](${n.link})`;this.editor.cm.focus(),this.editor.cm.replaceSelection(s),this.editor.cm.setCursor(e.line,e.ch+s.length)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=this.editor.cm.getCursor("from");kt.show(e,()=>Promise.resolve(""),n=>{let i={image:n,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",i).then(s=>{this.insertDrawing(s.data,t),kt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n),this.editor.cm.setCursor(t.line,t.ch+n.length)}editDrawing(e){let t=this.editor.config.drawioUrl;if(!t)return;let n=this.editor.cm.getCursor("from"),i=e.getAttribute("drawio-diagram");kt.show(t,()=>kt.load(i),s=>{let o={image:s,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",o).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=this.editor.cm.getValue().split(`
-`).map(u=>u.indexOf(`drawio-diagram="${i}"`)!==-1?l:u).join(`
-`);this.editor.cm.setValue(c),this.editor.cm.setCursor(n),this.editor.cm.focus(),kt.close()}).catch(a=>{this.handleDrawingUploadError(a)})})}handleDrawingUploadError(e){e.status===413?window.$events.emit("error",this.editor.config.text.serverUploadLimit):window.$events.emit("error",this.editor.config.text.imageUploadError),console.log(e)}fullScreen(){let e=this.editor.config.container,t=e.classList.contains("fullscreen");e.classList.toggle("fullscreen",!t),document.body.classList.toggle("markdown-fullscreen",!t)}scrollToText(e){if(!e)return;let n=this.editor.cm.getValue().split(/\r?\n/),i=n.findIndex(s=>s&&s.indexOf(e)!==-1);i!==-1&&(this.editor.cm.scrollIntoView({line:i},200),this.editor.cm.focus(),this.editor.cm.setCursor({line:i,char:n[i].length}))}focus(){this.editor.cm.focus()}insertContent(e){this.editor.cm.replaceSelection(e)}prependContent(e){let t=this.editor.cm.getCursor("from"),n=e+`
-`+this.editor.cm.getValue();this.editor.cm.setValue(n);let i=e.split(`
-`).length;this.editor.cm.setCursor(t.line+i,t.ch)}appendContent(e){let t=this.editor.cm.getCursor("from"),n=this.editor.cm.getValue()+`
-`+e;this.editor.cm.setValue(n),this.editor.cm.setCursor(t.line,t.ch)}replaceContent(e){this.editor.cm.setValue(e)}findAndReplaceContent(e,t){let n=this.editor.cm.getValue(),i=this.editor.cm.listSelections();this.editor.cm.setValue(n.replace(e,t)),this.editor.cm.setSelections(i)}replaceLineStart(e){let t=this.editor.cm.getCursor(),n=this.editor.cm.getLine(t.line),i=n.length,s=n.split(" ")[0];if(s===e){n=n.replace(`${e} `,""),this.editor.cm.replaceRange(n,{line:t.line,ch:0},{line:t.line,ch:i}),this.editor.cm.setCursor({line:t.line,ch:t.ch-(e.length+1)});return}let o=/^[#>`]/.test(s),a=0;o?(a=e.length-s.length,n=n.replace(s,e).trim()):e!==""&&(a=e.length+1,n=e+" "+n),this.editor.cm.replaceRange(n,{line:t.line,ch:0},{line:t.line,ch:i}),this.editor.cm.setCursor({line:t.line,ch:t.ch+a})}wrapLine(e,t){let n=this.editor.cm.getCursor(),i=this.editor.cm.getLine(n.line),s=i.length,o=i;i.indexOf(e)===0&&i.slice(-t.length)===t?o=i.slice(e.length,i.length-t.length):o=`${e}${i}${t}`,this.editor.cm.replaceRange(o,{line:n.line,ch:0},{line:n.line,ch:s}),this.editor.cm.setCursor({line:n.line,ch:n.ch+e.length})}wrapSelection(e,t){let n=this.editor.cm.getSelection();if(n==="")return this.wrapLine(e,t);let i=n,s=0,o;n.indexOf(e)===0&&n.slice(-t.length)===t?(i=n.slice(e.length,n.length-t.length),o=-(t.length+e.length)):(i=`${e}${n}${t}`,o=e.length+t.length);let a=this.editor.cm.listSelections()[0];this.editor.cm.replaceSelection(i);let l=a.head.ch<=a.anchor.ch;a.head.ch+=l?s:o,a.anchor.ch+=l?o:s,this.editor.cm.setSelections([a])}replaceLineStartForOrderedList(){let e=this.editor.cm.getCursor(),n=(this.editor.cm.getLine(e.line-1)||"").match(/^(\s*)(\d)([).])\s/)||[],i=(Number(n[2])||0)+1,s=n[1]||"",o=n[3]||".",a=`${s}${i}${o}`;return this.replaceLineStart(a)}cycleCalloutTypeAtSelection(){let e=this.editor.cm.listSelections()[0],t=this.editor.cm.getLine(e.anchor.line),n=t.length,i={anchor:{line:e.anchor.line,ch:0},head:{line:e.anchor.line,ch:n}},s=["info","success","warning","danger"],o=s.join("|"),l=new RegExp(`class="((${o})\\s+callout|callout\\s+(${o}))"`,"i").exec(t),c=(l?l[2]||l[3]:"").toLowerCase();if(c===s[s.length-1])this.wrapLine(`<p class="callout ${s[s.length-1]}">`,"</p>");else if(c==="")this.wrapLine('<p class="callout info">',"</p>");else{let u=s.indexOf(c)+1,d=s[u],h=t.replace(l[0],l[0].replace(c,d));this.editor.cm.replaceRange(h,i.anchor,i.head);let f=h.length-t.length;e.anchor.ch+=f,e.anchor!==e.head&&(e.head.ch+=f),this.editor.cm.setSelection(e.anchor,e.head)}}uploadImage(e){if(e===null||e.type.indexOf("image")!==0)return;let t="png";if(e.name){let u=e.name.match(/\.(.+)$/);u.length>1&&(t=u[1])}let n="image-"+Math.random().toString(16).slice(2),i=window.baseUrl(`/loading.gif#upload${n}`),s=this.editor.cm.getSelection(),o=``,a=this.editor.cm.getCursor();this.editor.cm.replaceSelection(o),this.editor.cm.setCursor({line:a.line,ch:a.ch+s.length+3});let l="image-"+Date.now()+"."+t,c=new FormData;c.append("file",e,l),c.append("uploaded_to",this.editor.config.pageId),window.$http.post("/images/gallery",c).then(u=>{let d=`[](${u.data.url})`;this.findAndReplaceContent(o,d)}).catch(u=>{window.$events.emit("error",this.editor.config.text.imageUploadError),this.findAndReplaceContent(o,s),console.log(u)})}syncDisplayPosition(){let e=this.editor.cm.getScrollInfo();if(e.top+e.clientHeight===e.height){this.editor.display.scrollToIndex(-1);return}let n=this.editor.cm.lineAtHeight(e.top,"local"),i=this.editor.cm.getRange({line:0,ch:null},{line:n,ch:null}),a=new DOMParser().parseFromString(this.editor.markdown.render(i),"text/html").documentElement.querySelectorAll("body > *");this.editor.display.scrollToIndex(a.length)}insertTemplate(e,t,n){let i=this.editor.cm.coordsChar({left:t,top:n});this.editor.cm.setCursor(i),window.$http.get(`/templates/${e}`).then(s=>{let o=s.data.markdown||s.data.html;this.editor.cm.replaceSelection(o)})}insertClipboardImages(e){let t=this.editor.cm.coordsChar({left:event.pageX,top:event.pageY});this.editor.cm.setCursor(t);for(let n of e)this.uploadImage(n)}};var Bi=class{constructor(e){this.settingMap={scrollSync:!0,showPreview:!0,editorWidth:50},this.changeListeners={},this.loadFromLocalStorage(),this.applyToInputs(e),this.listenToInputChanges(e)}applyToInputs(e){for(let t of e){let n=t.getAttribute("name").replace("md-","");t.checked=this.settingMap[n]}}listenToInputChanges(e){for(let t of e)t.addEventListener("change",n=>{let i=t.getAttribute("name").replace("md-","");this.set(i,t.checked)})}loadFromLocalStorage(){let e=window.localStorage.getItem("md-editor-settings");if(!e)return;let t=JSON.parse(e);for(let[n,i]of Object.entries(t))i!==null&&this.settingMap[n]!==void 0&&(this.settingMap[n]=i)}set(e,t){this.settingMap[e]=t,window.localStorage.setItem("md-editor-settings",JSON.stringify(this.settingMap));for(let n of this.changeListeners[e]||[])n(t)}get(e){return this.settingMap[e]||null}onChange(e,t){let n=this.changeListeners[e]||[];n.push(t),this.changeListeners[e]=n}};function Ni({html:r,markdown:e}){return e||r}function Qu(r){window.$events.listen("editor::replace",e=>{let t=Ni(e);r.actions.replaceContent(t)}),window.$events.listen("editor::append",e=>{let t=Ni(e);r.actions.appendContent(t)}),window.$events.listen("editor::prepend",e=>{let t=Ni(e);r.actions.prependContent(t)}),window.$events.listen("editor::insert",e=>{let t=Ni(e);r.actions.insertContent(t)}),window.$events.listen("editor::focus",()=>{r.actions.focus()})}function Ju(r,e){let t={};return t[`${e}-Alt-I`]=function(n){let s=``,o=n.getCursor("from");n.replaceSelection(s),n.setCursor(o.line,o.ch+s.length-1)},t[`${e}-S`]=n=>window.$events.emit("editor-save-draft"),t[`${e}-Enter`]=n=>window.$events.emit("editor-save-page"),t[`Shift-${e}-K`]=n=>r.actions.showLinkSelector(),t[`${e}-K`]=n=>r.actions.insertLink(),t[`${e}-1`]=n=>r.actions.replaceLineStart("##"),t[`${e}-2`]=n=>r.actions.replaceLineStart("###"),t[`${e}-3`]=n=>r.actions.replaceLineStart("####"),t[`${e}-4`]=n=>r.actions.replaceLineStart("#####"),t[`${e}-5`]=n=>r.actions.replaceLineStart(""),t[`${e}-D`]=n=>r.actions.replaceLineStart(""),t[`${e}-6`]=n=>r.actions.replaceLineStart(">"),t[`${e}-Q`]=n=>r.actions.replaceLineStart(">"),t[`${e}-7`]=n=>r.actions.wrapSelection("\n```\n","\n```"),t[`${e}-8`]=n=>r.actions.wrapSelection("`","`"),t[`Shift-${e}-E`]=n=>r.actions.wrapSelection("`","`"),t[`${e}-9`]=n=>r.actions.cycleCalloutTypeAtSelection(),t[`${e}-P`]=n=>r.actions.replaceLineStart("-"),t[`${e}-O`]=n=>r.actions.replaceLineStartForOrderedList(),t}var _s=class{constructor(e){this.data=e}hasItems(){return Boolean(this.data)&&Boolean(this.data.types)&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let e=this.data.types,t=this.data.files,n=[];for(let i of e)if(i.includes("image")){let s=this.data.getData(i);n.push(s.getAsFile())}for(let i of t)i.type.includes("image")&&n.push(i);return n}},pn=_s;async function ed(r){let e=await window.importVersioned("code"),t=e.markdownEditor(r.config.inputEl);t.setOption("direction","ltr"),t.setOption("extraKeys",Ju(r,e.getMetaKey())),t.on("change",(s,o)=>r.actions.updateAndRender());let n=Bt(r.actions.syncDisplayPosition.bind(r.actions),100,!1),i=r.settings.get("scrollSync");return r.settings.onChange("scrollSync",s=>i=s),t.on("scroll",s=>{i&&n(s)}),t.on("paste",(s,o)=>{let a=new pn(o.clipboardData||o.dataTransfer);if(!a.hasItems()||a.containsTabularData())return;let l=a.getImages();for(let c of l)r.actions.uploadImage(c)}),t.on("drop",(s,o)=>{let a=o.dataTransfer.getData("bookstack/template");a&&(o.preventDefault(),r.actions.insertTemplate(a,o.pageX,o.pageY));let c=new pn(o.dataTransfer).getImages();c.length>0&&(o.stopPropagation(),o.preventDefault(),r.actions.insertClipboardImages(c))}),t}async function td(r){let e={config:r,markdown:new Oi,settings:new Bi(r.settingInputs)};return e.actions=new _i(e),e.display=new $i(e),e.cm=await ed(e),Qu(e),e}var Ui=class extends V{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.display=this.$refs.display,this.input=this.$refs.input,this.divider=this.$refs.divider,this.displayWrap=this.$refs.displayWrap;let t=this.$refs.settingContainer.querySelectorAll('input[type="checkbox"]');this.editor=null,td({pageId:this.pageId,container:this.elem,displayEl:this.display,inputEl:this.input,drawioUrl:this.getDrawioUrl(),settingInputs:Array.from(t),text:{serverUploadLimit:this.serverUploadLimitText,imageUploadError:this.imageUploadErrorText}}).then(n=>{this.editor=n,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,codeMirrorInstance:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",n=>{let i=n.target.closest("button[data-action]");if(i===null)return;let s=i.getAttribute("data-action");if(s==="insertImage"&&this.editor.actions.insertImage(),s==="insertLink"&&this.editor.actions.showLinkSelector(),s==="insertDrawing"&&(n.ctrlKey||n.metaKey)){this.editor.actions.showImageManager();return}s==="insertDrawing"&&this.editor.actions.startDrawing(),s==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",n=>{let i=n.target.closest(".editor-toolbar-label");if(!i)return;let s=this.elem.querySelectorAll(".markdown-editor-wrap");for(let o of s)o.classList.remove("active");i.closest(".markdown-editor-wrap").classList.add("active")});let e=Bt(()=>this.editor.cm.refresh(),100,!1);new ResizeObserver(e).observe(this.elem),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",t=>{let n=this.elem.getBoundingClientRect(),i=o=>{let a=o.pageX-n.left,l=Math.min(Math.max(20,Math.floor(a/n.width*100)),80);this.displayWrap.style.flexBasis=`${100-l}%`,this.editor.settings.set("editorWidth",l)},s=o=>{window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",s),this.display.style.pointerEvents=null,document.body.style.userSelect=null,this.editor.cm.refresh()};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",i),window.addEventListener("pointerup",s)});let e=this.editor.settings.get("editorWidth");e&&(this.displayWrap.style.flexBasis=`${100-e}%`)}scrollToTextIfNeeded(){let t=new URL(window.location).searchParams.get("content-text");t&&this.editor.actions.scrollToText(t)}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e&&e.getAttribute("drawio-url")||""}getContent(){return this.editor.actions.getContent()}};var zi=class extends V{setup(){this.container=this.$el,this.inputContainer=this.$refs.inputContainer,this.inviteOption=this.container.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let e=this.inviteOption.value==="true",t=this.container.querySelectorAll("input[type=password]");for(let n of t)n.disabled=e;this.inputContainer.style.display=e?"none":"block"}};var ji=class extends V{setup(){this.container=this.$el,this.type=this.$opts.type,this.textElem=this.container.querySelector("span"),this.autoHide=this.$opts.autoHide==="true",this.initialShow=this.$opts.show==="true",this.container.style.display="grid",window.$events.listen(this.type,e=>{this.show(e)}),this.container.addEventListener("click",this.hide.bind(this)),this.initialShow&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(e=""){if(this.container.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=e,this.container.style.display="grid",setTimeout(()=>{this.container.classList.add("showing")},1),this.autoHide){let t=e.split(" ").length,n=Math.max(2e3,1e3+250*t);setTimeout(this.hide.bind(this),n)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Hi=class extends V{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){je(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),je(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};var Vi=class extends V{setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.formContainer=this.$refs.formContainer,this.commentCountBar=this.$refs.commentCountBar,this.addButtonContainer=this.$refs.addButtonContainer,this.replyToRow=this.$refs.replyToRow,this.updatedText=this.$opts.updatedText,this.deletedText=this.$opts.deletedText,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.editingComment=null,this.parentId=null,this.formContainer&&(this.form=this.formContainer.querySelector("form"),this.formInput=this.form.querySelector("textarea"),this.form.addEventListener("submit",this.saveComment.bind(this))),this.elem.addEventListener("click",this.handleAction.bind(this)),this.elem.addEventListener("submit",this.updateComment.bind(this))}handleAction(e){let t=e.target.closest("[action]");if(e.target.matches('a[href^="#"]')){let s=e.target.href.split("#")[1];jr(document.querySelector("#"+s))}if(t===null)return;e.preventDefault();let n=t.getAttribute("action"),i=t.closest("[comment]");n==="edit"&&this.editComment(i),n==="closeUpdateForm"&&this.closeUpdateForm(),n==="delete"&&this.deleteComment(i),n==="addComment"&&this.showForm(),n==="hideForm"&&this.hideForm(),n==="reply"&&this.setReply(i),n==="remove-reply-to"&&this.removeReplyTo()}closeUpdateForm(){this.editingComment&&(this.editingComment.querySelector("[comment-content]").style.display="block",this.editingComment.querySelector("[comment-edit-container]").style.display="none")}editComment(e){this.hideForm(),this.editingComment&&this.closeUpdateForm(),e.querySelector("[comment-content]").style.display="none",e.querySelector("[comment-edit-container]").style.display="block";let t=e.querySelector("[comment-edit-container] textarea"),n=t.value.split(`
-`).length;t.style.height=n*20+40+"px",this.editingComment=e}updateComment(e){let t=e.target;e.preventDefault();let i={text:t.querySelector("textarea").value,parent_id:this.parentId||null};this.showLoading(t);let s=this.editingComment.getAttribute("comment");window.$http.put(`/comment/${s}`,i).then(o=>{let a=document.createElement("div");a.innerHTML=o.data,this.editingComment.innerHTML=a.children[0].innerHTML,window.$events.success(this.updatedText),window.$components.init(this.editingComment),this.closeUpdateForm(),this.editingComment=null}).catch(window.$events.showValidationErrors).then(()=>{this.hideLoading(t)})}deleteComment(e){let t=e.getAttribute("comment");this.showLoading(e.querySelector("[comment-content]")),window.$http.delete(`/comment/${t}`).then(n=>{e.parentNode.removeChild(e),window.$events.success(this.deletedText),this.updateCount(),this.hideForm()})}saveComment(e){e.preventDefault(),e.stopPropagation();let n={text:this.formInput.value,parent_id:this.parentId||null};this.showLoading(this.form),window.$http.post(`/comment/${this.pageId}`,n).then(i=>{let s=tr(i.data);this.container.appendChild(s),window.$components.init(s),window.$events.success(this.createdText),this.resetForm(),this.updateCount()}).catch(i=>{window.$events.showValidationErrors(i),this.hideLoading(this.form)})}updateCount(){let e=this.container.children.length;this.elem.querySelector("[comments-title]").textContent=window.trans_plural(this.countText,e,{count:e})}resetForm(){this.formInput.value="",this.formContainer.appendChild(this.form),this.hideForm(),this.removeReplyTo(),this.hideLoading(this.form)}showForm(){this.formContainer.style.display="block",this.formContainer.parentNode.style.display="block",this.addButtonContainer.style.display="none",this.formInput.focus(),this.formInput.scrollIntoView({behavior:"smooth"})}hideForm(){this.formContainer.style.display="none",this.formContainer.parentNode.style.display="none",this.getCommentCount()>0?this.elem.appendChild(this.addButtonContainer):this.commentCountBar.appendChild(this.addButtonContainer),this.addButtonContainer.style.display="block"}getCommentCount(){return this.elem.querySelectorAll(".comment-box[comment]").length}setReply(e){this.showForm(),this.parentId=Number(e.getAttribute("local-id")),this.replyToRow.style.display="block";let t=this.replyToRow.querySelector("a");t.textContent=`#${this.parentId}`,t.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.style.display="none"}showLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="none";e.querySelector(".form-group.loading").style.display="block"}hideLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="block";e.querySelector(".form-group.loading").style.display="none"}};var qi=class extends V{setup(){if(this.container=this.$el,this.pageId=this.$opts.pageId,window.importVersioned("code").then(t=>t.highlight()),this.setupNavHighlighting(),this.setupDetailsCodeBlockRefresh(),window.location.hash){let t=window.location.hash.replace(/%20/g," ").substring(1);this.goToText(t)}let e=document.querySelector(".sidebar-page-nav");e&&Ge(e,"a","click",(t,n)=>{t.preventDefault(),window.$components.first("tri-layout").showContent();let i=n.getAttribute("href").substr(1);this.goToText(i),window.history.pushState(null,null,"#"+i)})}goToText(e){let t=document.getElementById(e);if(To(".page-content [data-highlighted]",n=>{n.removeAttribute("data-highlighted"),n.style.backgroundColor=null}),t!==null)jr(t);else{let n=Zs(".page-content > div > *",e);n&&jr(n)}}setupNavHighlighting(){let e=document.querySelector(".sidebar-page-nav"),t=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");t.length>0&&e!==null&&n(t);function n(o){let a={rootMargin:"0px 0px 0px 0px",threshold:1},l=new IntersectionObserver(i,a);for(let c of o)l.observe(c)}function i(o,a){for(let l of o){let c=l.intersectionRatio===1;s(l.target.id,c)}}function s(o,a){To('a[href="#'+o+'"]',l=>{l.closest("li").classList.toggle("current-heading",a)})}}setupDetailsCodeBlockRefresh(){let e=n=>{[...n.target.querySelectorAll(".CodeMirror")].forEach(s=>s.CodeMirror&&s.CodeMirror.refresh())};[...this.container.querySelectorAll("details")].forEach(n=>n.addEventListener("toggle",e))}};function rd(r){let e=new Date(r*1e3),t=e.getHours(),n=e.getMinutes();return`${(t>9?"":"0")+t}:${(n>9?"":"0")+n}`}var Gi=class extends V{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.changeEditorButtons=this.$manyRefs.changeEditor,this.switchDialogContainer=this.$refs.switchDialog,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.setChangelogText=this.$opts.setChangelogText,this.autoSave={interval:null,frequency:3e4,last:0,pendingChange:!1},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this));let e=()=>this.autoSave.pendingChange=!0;window.$events.listen("editor-html-change",e),window.$events.listen("editor-markdown-change",e),this.titleElem.addEventListener("input",e);let t=Bt(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",t),je(this.saveDraftButton,this.saveDraft.bind(this)),je(this.discardDraftButton,this.discardDraft.bind(this)),je(this.changeEditorButtons,this.changeEditor.bind(this))}setInitialFocus(){if(this.hasDefaultTitle)return this.titleElem.select();window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){this.autoSave.interval=window.setInterval(this.runAutoSave.bind(this),this.autoSave.frequency)}runAutoSave(){Date.now()-this.autoSave.last<this.autoSave.frequency/2||!this.autoSave.pendingChange||this.saveDraft()}savePage(){this.container.closest("form").submit()}async saveDraft(){let e={name:this.titleElem.value.trim()},t=this.getEditorComponent().getContent();Object.assign(e,t);let n=!1;try{let i=await window.$http.put(`/ajax/page/${this.pageId}/save-draft`,e);this.isNewDraft||this.toggleDiscardDraftVisibility(!0),this.draftNotifyChange(`${i.data.message} ${rd(i.data.timestamp)}`),this.autoSave.last=Date.now(),i.data.warning&&!this.shownWarningsCache.has(i.data.warning)&&(window.$events.emit("warning",i.data.warning),this.shownWarningsCache.add(i.data.warning)),n=!0,this.autoSave.pendingChange=!1}catch{try{let s=`draft-save-fail-${new Date().toISOString()}`;window.localStorage.setItem(s,JSON.stringify(e))}catch{}window.$events.emit("error",this.autosaveFailText)}return n}draftNotifyChange(e){this.draftDisplay.innerText=e,this.draftDisplayIcon.classList.add("visible"),window.setTimeout(()=>{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(){let e;try{e=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(t){return console.error(t)}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.toggleDiscardDraftVisibility(!1),window.$events.emit("editor::replace",{html:e.data.html,markdown:e.data.markdown}),this.titleElem.value=e.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),window.$events.emit("success",this.draftDiscardedText)}updateChangelogDisplay(){let e=this.changelogInput.value.trim();e.length===0?e=this.setChangelogText:e.length>16&&(e=e.slice(0,16)+"..."),this.changelogDisplay.innerText=e}toggleDiscardDraftVisibility(e){this.discardDraftWrap.classList.toggle("hidden",!e)}async changeEditor(e){e.preventDefault();let t=e.target.closest("a").href,n=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[i,s]=await Promise.all([this.saveDraft(),n.show()]);i&&s&&(window.location=t)}getEditorComponent(){return window.$components.first("markdown-editor")||window.$components.first("wysiwyg-editor")}};var Yi=class extends V{setup(){this.input=this.$refs.input,this.resetButton=this.$refs.resetButton,this.selectButton=this.$refs.selectButton,this.display=this.$refs.display,this.defaultDisplay=this.$refs.defaultDisplay,this.buttonSep=this.$refs.buttonSeperator,this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.resetButton.addEventListener("click",e=>{this.setValue("","")})}showPopup(){window.$components.first("entity-selector-popup").show(t=>{this.setValue(t.id,t.name)})}setValue(e,t){this.value=e,this.input.value=e,this.controlView(t)}controlView(e){let t=this.value&&this.value!==0;if(Wi(this.resetButton,t),Wi(this.buttonSep,t),Wi(this.defaultDisplay,!t),Wi(this.display,t),t){let n=this.getAssetIdFromVal();this.display.textContent=`#${n}, ${e}`,this.display.href=window.baseUrl(`/link/${n}`)}}getAssetIdFromVal(){return Number(this.value)}};function Wi(r,e){r.style.display=e?null:"none"}var Ki=class extends V{setup(){this.container=this.$el,this.cellSelector=this.$opts.cellSelector||"td,th",this.rowSelector=this.$opts.rowSelector||"tr";for(let e of this.$manyRefs.toggleAll||[])e.addEventListener("click",this.toggleAllClick.bind(this));for(let e of this.$manyRefs.toggleRow||[])e.addEventListener("click",this.toggleRowClick.bind(this));for(let e of this.$manyRefs.toggleColumn||[])e.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(e){e.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(e){e.preventDefault(),this.toggleAllInElement(e.target.closest(this.rowSelector))}toggleColumnClick(e){e.preventDefault();let t=e.target.closest(this.cellSelector),n=Array.from(t.parentElement.children).indexOf(t),i=this.container.querySelectorAll(this.rowSelector),s=[];for(let o of i){let a=o.children[n];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(e){let t=e.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(t)}toggleAllInputs(e){let t=e.length>0?e[0].checked:!1;for(let n of e)n.checked=!t,n.dispatchEvent(new Event("change"))}};var id=gn(nd());var Xi=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.showing=!1,this.isSelection=!1,this.pointerModeLink=!0,this.pointerSectionId="",this.setupListeners(),new id.default(this.container.querySelector("button"))}setupListeners(){Ge(this.container,"input","click",(t,n)=>{n.select(),t.stopPropagation()}),bn(this.container,["click","focus"],t=>{t.stopPropagation()}),Ge(this.container,"span.icon","click",(t,n)=>{t.stopPropagation(),this.pointerModeLink=!this.pointerModeLink,n.querySelector('[data-icon="include"]').style.display=this.pointerModeLink?"none":"inline",n.querySelector('[data-icon="link"]').style.display=this.pointerModeLink?"inline":"none",this.updateForTarget()}),bn(document.body,["click","focus"],t=>{!this.showing||this.isSelection||this.hidePointer()});let e=document.querySelector(".page-content");bn(e,["mouseup","keyup"],t=>{t.stopPropagation();let n=t.target.closest('[id^="bkmrk"]');n&&this.showPointerAtTarget(n,t.pageX)})}hidePointer(){this.container.style.display=null,this.showing=!1}showPointerAtTarget(e,t){if(window.getSelection().toString().length===0)return;this.pointerSectionId=e.id,this.updateForTarget(e),this.container.style.display="block";let i=e.getBoundingClientRect(),s=this.container.getBoundingClientRect(),a=Math.min(Math.max(t,i.left),i.right)-s.width/2,l=i.top-s.height-16;this.container.style.left=`${a}px`,this.container.style.top=`${l}px`,this.showing=!0,this.isSelection=!0,setTimeout(()=>{this.isSelection=!1},100);let c=()=>{this.hidePointer(),window.removeEventListener("scroll",c,{passive:!0})};window.addEventListener("scroll",c,{passive:!0})}updateForTarget(e){let t=this.pointerModeLink?window.baseUrl(`/link/${this.pageId}#${this.pointerSectionId}`):`{{@${this.pageId}#${this.pointerSectionId}}}`;this.pointerModeLink&&!t.startsWith("http")&&(t=window.location.protocol+"//"+window.location.host+t),this.container.querySelector("input").value=t;let n=this.container.querySelector("#pointer-edit");if(n&&e){let i=n.dataset.editHref,s=e.id,o=e.textContent&&e.textContent.substring(0,50);n.href=`${i}?content-id=${s}&content-text=${encodeURIComponent(o)}`}}};var Zi=class extends V{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let e=null;this.container.addEventListener("mousedown",t=>{e=t.target}),this.container.addEventListener("click",t=>{if(t.target===this.container&&e===this.container)return this.hide()}),je(this.hideButtons,t=>this.hide())}hide(e=null){Yn(this.container,120,e),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(e=null,t=null){Ta(this.container,120,e),this.onkeyup=n=>{n.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=t}};var Qi=class extends V{setup(){this.container=this.$el,this.mode=this.$opts.mode,this.lightContainer=this.$refs.lightContainer,this.darkContainer=this.$refs.darkContainer,this.container.addEventListener("tabs-change",t=>{let i=t.detail.showing==="color-scheme-panel-light"?"light":"dark";this.handleModeChange(i)});let e=t=>{this.updateAppColorsFromInputs(),t.target.name.startsWith("setting-app-color")&&this.updateLightForInput(t.target)};this.container.addEventListener("change",e),this.container.addEventListener("input",e)}handleModeChange(e){this.mode=e;let t=e==="dark";document.documentElement.classList.toggle("dark-mode",t),this.updateAppColorsFromInputs()}updateAppColorsFromInputs(){let t=(this.mode==="dark"?this.darkContainer:this.lightContainer).querySelectorAll('input[type="color"]');for(let n of t){let i=n.name.split("-"),s=i.indexOf("color"),o=i.slice(1,s).join("-");o==="app"&&(o="primary");let a="--color-"+o;document.body.style.setProperty(a,n.value)}}updateLightForInput(e){let t=e.name.replace("-color","-color-light"),n=e.value,i=this.hexToRgb(n),s="rgba("+[i.r,i.g,i.b,"0.15"].join(",")+")";console.log(e.name,t,n,s);let o=this.container.querySelector(`input[name="${t}"][type="hidden"]`);o.value=s}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return{r:t?parseInt(t[1],16):0,g:t?parseInt(t[2],16):0,b:t?parseInt(t[3],16):0}}};var Ji=class extends V{setup(){this.colorInput=this.$refs.input,this.resetButton=this.$refs.resetButton,this.defaultButton=this.$refs.defaultButton,this.currentColor=this.$opts.current,this.defaultColor=this.$opts.default,this.resetButton.addEventListener("click",()=>this.setValue(this.currentColor)),this.defaultButton.addEventListener("click",()=>this.setValue(this.defaultColor))}setValue(e){this.colorInput.value=e,this.colorInput.dispatchEvent(new Event("change",{bubbles:!0}))}};var eo=class extends V{setup(){this.typeControl=this.$refs.typeControl,this.pagePickerContainer=this.$refs.pagePickerContainer,this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}};var Fm={move_up(r,e,t){let n=r.parentNode,i=Array.from(n.children).indexOf(r),s=Math.max(i-1,0);n.insertBefore(r,n.children[s]||null)},move_down(r,e,t){let n=r.parentNode,i=Array.from(n.children).indexOf(r),s=Math.min(i+2,n.children.length);n.insertBefore(r,n.children[s]||null)},remove(r,e,t){t.appendChild(r)},add(r,e,t){e.appendChild(r)}},to=class extends V{setup(){this.elem=this.$el,this.input=this.$refs.input,this.shelfBookList=this.$refs.shelfBookList,this.allBookList=this.$refs.allBookList,this.bookSearchInput=this.$refs.bookSearch,this.sortButtonContainer=this.$refs.sortButtonContainer,this.lastSort=null,this.initSortable(),this.setupListeners()}initSortable(){let e=this.elem.querySelectorAll(".scroll-box");for(let t of e)new hr(t,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){this.elem.addEventListener("click",e=>{let t=e.target.closest(".scroll-box-item button[data-action]");t&&this.sortItemActionClick(t)}),this.bookSearchInput.addEventListener("input",e=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",e=>{let t=e.target.closest("button[data-sort]");t&&this.sortShelfBooks(t.dataset.sort)})}filterBooksByName(e){this.allBookList.style.height||(this.allBookList.style.height=this.allBookList.getBoundingClientRect().height+"px");let t=this.allBookList.children,n=e.trim().toLowerCase();for(let i of t){let s=!e||i.textContent.toLowerCase().includes(n);i.style.display=s?null:"none"}}sortItemActionClick(e){let t=e.closest(".scroll-box-item"),n=e.dataset.action,i=Fm[n];i(t,this.shelfBookList,this.allBookList),this.onChange()}onChange(){let e=Array.from(this.shelfBookList.querySelectorAll("[data-id]"));this.input.value=e.map(t=>t.getAttribute("data-id")).join(",")}sortShelfBooks(e){let t=Array.from(this.shelfBookList.children),n=e===this.lastSort;t.sort((i,s)=>{let o=i.dataset[e].toLowerCase(),a=s.dataset[e].toLowerCase();return n?o<a?o===a?0:1:-1:o<a?o===a?0:-1:1});for(let i of t)this.shelfBookList.append(i);this.lastSort=this.lastSort===e?null:e,this.onChange()}};function Rm(r){let e={};for(let[t,n]of Object.entries(r))e[n]=t;return e}var ro=class extends V{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=Rm(this.mapById),this.hintsShowing=!1,this.hideHints=this.hideHints.bind(this),this.setupListeners()}setupListeners(){window.addEventListener("keydown",e=>{e.target.closest("input, select, textarea")||this.handleShortcutPress(e)}),window.addEventListener("keydown",e=>{e.key==="?"&&(this.hintsShowing?this.hideHints():this.showHints())})}handleShortcutPress(e){let n=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key].filter(s=>Boolean(s)).join(" + "),i=this.mapByShortcut[n];i&&this.runShortcut(i)&&e.preventDefault()}runShortcut(e){let t=this.container.querySelector(`[data-shortcut="${e}"]`);return t?t.matches("input, textarea, select")?(t.focus(),!0):t.matches("a, button")?(t.click(),!0):t.matches("div[tabindex]")?(t.click(),t.focus(),!0):(console.error("Shortcut attempted to be ran for element type that does not have handling setup",t),!1):!1}showHints(){let e=document.createElement("div");e.classList.add("shortcut-container"),this.container.append(e);let t=this.container.querySelectorAll("[data-shortcut]"),n=new Set;for(let i of t){let s=i.getAttribute("data-shortcut");if(n.has(s))continue;let o=this.mapById[s];this.showHintLabel(i,o,e),n.add(s)}window.addEventListener("scroll",this.hideHints),window.addEventListener("focus",this.hideHints),window.addEventListener("blur",this.hideHints),window.addEventListener("click",this.hideHints),this.hintsShowing=!0}showHintLabel(e,t,n){let i=e.getBoundingClientRect(),s=document.createElement("div");s.classList.add("shortcut-hint"),s.textContent=t;let o=document.createElement("div");o.classList.add("shortcut-linkage"),o.style.left=i.x+"px",o.style.top=i.y+"px",o.style.width=i.width+"px",o.style.height=i.height+"px",n.append(s,o);let a=s.getBoundingClientRect();s.style.insetInlineStart=`${i.x+i.width-(a.width+6)}px`,s.style.insetBlockStart=`${i.y+(i.height-a.height)/2}px`}hideHints(){this.container.querySelector(".shortcut-container").remove(),window.removeEventListener("scroll",this.hideHints),window.removeEventListener("focus",this.hideHints),window.removeEventListener("blur",this.hideHints),window.removeEventListener("click",this.hideHints),this.hintsShowing=!1}};var Om=["Control","Alt","Shift","Meta","Super"," ","+","Tab","Escape"],no=class extends V{setup(){this.input=this.$el,this.setupListeners()}setupListeners(){this.listenerRecordKey=this.listenerRecordKey.bind(this),this.input.addEventListener("focus",()=>{this.startListeningForInput()}),this.input.addEventListener("blur",()=>{this.stopListeningForInput()})}startListeningForInput(){this.input.addEventListener("keydown",this.listenerRecordKey)}listenerRecordKey(e){if(Om.includes(e.key))return;let t=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key];this.input.value=t.filter(n=>Boolean(n)).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var io=class extends V{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let e=new hr(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:e.toArray()})},setData(t,n){let i=n.getAttribute("data-drag-content");if(i){let s=JSON.parse(i);for(let[o,a]of Object.entries(s))t.setData(o,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}};var oo=class extends V{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",e=>{if(this.filter&&!e.target.matches(this.filter))return;let t=this.$el.closest("form");t&&t.submit()})}};var so=class extends V{setup(){this.container=this.$el,this.tabs=Array.from(this.container.querySelectorAll('[role="tab"]')),this.panels=Array.from(this.container.querySelectorAll('[role="tabpanel"]')),this.container.addEventListener("click",e=>{let t=e.target.closest('[role="tab"]');t&&this.show(t.getAttribute("aria-controls"))})}show(e){for(let t of this.panels)t.toggleAttribute("hidden",t.id!==e);for(let t of this.tabs){let i=t.getAttribute("aria-controls")===e;t.setAttribute("aria-selected",i?"true":"false")}this.$emit("change",{showing:e})}};var ao=class extends V{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("input",e=>{let t=window.$components.firstOnElement(this.addRemoveComponentEl,"add-remove-rows");!this.hasEmptyRows()&&e.target.value&&t.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(n=>[...n.querySelectorAll("input")].filter(i=>i.value).length===0)!==void 0}};var lo=class extends V{setup(){this.container=this.$el,this.list=this.$refs.list,this.searchInput=this.$refs.searchInput,this.searchButton=this.$refs.searchButton,this.searchCancel=this.$refs.searchCancel,this.setupListeners()}setupListeners(){Ge(this.container,"[template-action]","click",this.handleTemplateActionClick.bind(this)),Ge(this.container,".pagination a","click",this.handlePaginationClick.bind(this)),Ge(this.container,".template-item-content","click",this.handleTemplateItemClick.bind(this)),Ge(this.container,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.searchInput.addEventListener("keypress",e=>{e.key==="Enter"&&(e.preventDefault(),this.performSearch())}),this.searchButton.addEventListener("click",e=>this.performSearch()),this.searchCancel.addEventListener("click",e=>{this.searchInput.value="",this.performSearch()})}handleTemplateItemClick(e,t){let n=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(n,"replace")}handleTemplateItemDragStart(e,t){let n=t.closest("[template-id]").getAttribute("template-id");e.dataTransfer.setData("bookstack/template",n),e.dataTransfer.setData("text/plain",n)}handleTemplateActionClick(e,t){e.stopPropagation();let n=t.getAttribute("template-action"),i=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(i,n)}async insertTemplate(e,t="replace"){let n=await window.$http.get(`/templates/${e}`),i="editor::"+t;window.$events.emit(i,n.data)}async handlePaginationClick(e,t){e.preventDefault();let n=t.getAttribute("href"),i=await window.$http.get(n);this.list.innerHTML=i.data}async performSearch(){let e=this.searchInput.value,t=await window.$http.get("/templates",{search:e});this.searchCancel.style.display=e?"block":"none",this.list.innerHTML=t.data}};var co=class extends V{setup(){this.input=this.$el.querySelector("input[type=hidden]"),this.checkbox=this.$el.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let e=new Event("change");this.input.dispatchEvent(e)}};var uo=class extends V{setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.lastLayoutType="none",this.onDestroy=null,this.scrollCache={content:0,info:0},this.lastTabShown="content",this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",e=>{this.updateLayout()},{passive:!0})}updateLayout(){let e="tablet";window.innerWidth<=1e3&&(e="mobile"),window.innerWidth>=1400&&(e="desktop"),e!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),e==="desktop"?this.setupDesktop():e==="mobile"&&this.setupMobile(),this.lastLayoutType=e)}setupMobile(){for(let e of this.tabs)e.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let e of this.tabs)e.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(e){let t=e.target.dataset.tab;this.showTab(t)}showContent(){this.showTab("content",!1)}showTab(e,t=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let i of this.tabs){let s=i.dataset.tab===e;i.setAttribute("aria-selected",s?"true":"false")}let n=e==="info";if(this.container.classList.toggle("show-info",n),t){let s=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[e]||s,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[e]||s},50)}this.lastTabShown=e}};var ho=class extends V{setup(){this.container=this.$el,this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,Ge(this.container,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(e,t){e.preventDefault(),this.input.value=t.getAttribute("data-id"),this.userInfoContainer.innerHTML=t.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}hide(){window.$components.firstOnElement(this.container,"dropdown").hide()}};var fo=class extends V{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",e=>{e.target.checked&&e.target===this.allCheckbox?this.deselectIndividualEvents():e.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let e of this.checkboxes)e!==this.allCheckbox&&(e.checked=!1)}};function od(r){for(let e=1;e<5;e++)r.shortcuts.add("meta+"+e,"",["FormatBlock",!1,"h"+(e+1)]);r.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+o","","InsertOrderedList"),r.shortcuts.add("meta+p","","InsertUnorderedList"),r.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),r.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),r.shortcuts.add("meta+9","",function(){let e=r.selection.getNode(),t=e?e.closest(".callout"):null,n=["info","success","warning","danger"],s=(n.findIndex(a=>t&&t.classList.contains(a))+1)%n.length,o=n[s];r.formatter.apply("callout"+o)}),r.shortcuts.add("meta+shift+K","",function(){window.$components.first("entity-selector-popup").show(function(t){r.selection.isCollapsed()?r.insertContent(r.dom.createHTML("a",{href:t.link},r.dom.encode(t.name))):r.formatter.apply("link",{href:t.link}),r.selection.collapse(!1),r.focus()})})}function sd(r){window.$events.listen("editor::replace",({html:e})=>{r.setContent(e)}),window.$events.listen("editor::append",({html:e})=>{let t=r.getContent()+e;r.setContent(t)}),window.$events.listen("editor::prepend",({html:e})=>{let t=e+r.getContent();r.setContent(t)}),window.$events.listen("editor::insert",({html:e})=>{r.insertContent(e)}),window.$events.listen("editor::focus",()=>{r.initialized&&r.focus()})}function ad(r){let t=new URL(window.location).searchParams.get("content-id");t&&Pm(r,t)}function Pm(r,e){let t=r.dom.get(encodeURIComponent(e).replace(/!/g,"%21"));t&&(t.scrollIntoView(),r.selection.select(t,!0),r.selection.collapse(!1),r.focus())}var gr,po;function Mm(r){return r&&!!(r.textContent||r.innerText)}function ld(r,e,t){let n=new pn(t.clipboardData||t.dataTransfer);if(!n.hasItems()||n.containsTabularData())return;let i=n.getImages();for(let s of i){let o="image-"+Math.random().toString(16).slice(2),a=window.baseUrl("/loading.gif");t.preventDefault(),setTimeout(()=>{r.insertContent(`<p><img src="${a}" id="${o}"></p>`),$m(s,e.pageId).then(l=>{let c=l.name.replace(/"/g,""),u=`<img src="${l.thumbs.display}" alt="${c}" />`,d=r.dom.create("a",{target:"_blank",href:l.url},u);r.dom.replace(d,o)}).catch(l=>{r.dom.remove(o),window.$events.emit("error",e.translations.imageUploadErrorText),console.log(l)})},10)}}async function $m(r,e){if(r===null||r.type.indexOf("image")!==0)throw new Error("Not an image file");let t=r.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",r,t),n.append("uploaded_to",e),(await window.$http.post(window.baseUrl("/images/gallery"),n)).data}function _m(r,e){let t=r.selection.getNode();t.nodeName==="IMG"&&(gr=r.dom.getParent(t,".mceTemp"),!gr&&t.parentNode.nodeName==="A"&&!Mm(t.parentNode)&&(gr=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(po=t)}function Bm(r,e,t){let n=r.dom,i=tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX,t.clientY,r.getDoc()),s=t.dataTransfer&&t.dataTransfer.getData("bookstack/template");s&&(t.preventDefault(),window.$http.get(`/templates/${s}`).then(o=>{r.selection.setRng(i),r.undoManager.transact(function(){r.execCommand("mceInsertContent",!1,o.data.html)})})),n.getParent(i.startContainer,".mceTemp")?t.preventDefault():gr&&(t.preventDefault(),r.undoManager.transact(function(){r.selection.setRng(i),r.selection.setNode(gr),n.remove(gr)})),!t.isDefaultPrevented()&&po&&(t.preventDefault(),r.undoManager.transact(function(){let o=r.selection.getNode(),a=r.selection.getRng(),l=o.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(po):l.before(po)})),t.isDefaultPrevented()||ld(r,e,t),gr=null}function cd(r,e){r.on("dragstart",()=>_m(r,e)),r.on("drop",t=>Bm(r,e,t)),r.on("paste",t=>ld(r,e,t))}function ud(r){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",r.textDirection==="rtl"?"ltr rtl":"","link table imagemanager-insert insertoverflow","code about fullscreen"].filter(n=>Boolean(n)).join(" | ")}function Nm(r){r.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),r.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),r.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function Um(r){r.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(e){return e.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function zm(r){r.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(e){return e.closest("img")!==null},position:"node",scope:"node",items:"image"})}function dd(r,e){Nm(r),Um(r),zm(r)}var jm={"table-delete-column":'<svg width="24" height="24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>',"table-delete-row":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>',"table-insert-column-after":'<svg width="24" height="24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>',"table-insert-column-before":'<svg width="24" height="24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>',"table-insert-row-above":'<svg width="24" height="24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>',"table-insert-row-after":'<svg width="24" height="24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>',table:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2ZM5 14v5h6v-5zm14 0h-6v5h6zm0-7h-6v5h6zM5 12h6V7H5Z"/></svg>',"table-delete-table":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>'};function hd(r){for(let[e,t]of Object.entries(jm))r.ui.registry.addIcon(e,t)}function fd(r){return r.tagName.toLowerCase()==="code-block"}function md(r,e,t,n){window.$components.first("code-editor").open(e,t,(i,s)=>{n(i,s),r.focus()})}function pd(r,e){md(r,e.getContent(),e.getLanguage(),(t,n)=>{e.setContent(t,n)})}function Hm(r){let e=r.getDoc(),t=e.defaultView;class n extends t.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});let s=document.querySelectorAll('link[rel="stylesheet"]:not([media="print"])'),o=Array.from(s).map(l=>l.cloneNode(!1)),a=document.createElement("div");a.style.pointerEvents="none",a.contentEditable="false",a.classList.add("CodeMirrorContainer"),this.shadowRoot.append(...o,a)}getLanguage(){let s=l=>(l.split(" ").filter(u=>u.startsWith("language-"))[0]||"").replace("language-",""),o=this.querySelector("code"),a=this.querySelector("pre");return s(a.className)||o&&s(o.className)||""}setContent(s,o){this.cm&&importVersioned("code").then(c=>{c.setContent(this.cm,s),c.setMode(this.cm,o,s)});let a=this.querySelector("pre");a||(a=e.createElement("pre"),this.append(a)),a.innerHTML="";let l=e.createElement("code");a.append(l),l.innerText=s,l.className=`language-${o}`}getContent(){let s=this.querySelector("code")||this.querySelector("pre"),o=document.createElement("pre");o.innerHTML=s.innerHTML.replace(/\ufeff/g,"");let a=o.querySelectorAll("br");for(let l of a)l.replaceWith(`
-`);return o.textContent}connectedCallback(){let s=Date.now();if(this.cm)return;this.cleanChildContent();let o=this.getContent(),l=o.split(`
-`).length*19.2+18+24;this.style.height=`${l}px`;let c=this.shadowRoot.querySelector(".CodeMirrorContainer"),u=d=>{this.cm=d.wysiwygView(c,o,this.getLanguage()),setTimeout(()=>d.updateLayout(this.cm),10),setTimeout(()=>this.style.height=null,12)};window.importVersioned("code").then(d=>{let h=Date.now()-s<20?20:0;setTimeout(()=>u(d),h)})}cleanChildContent(){let s=this.querySelector("pre");if(s)for(let o of s.childNodes)o.nodeName==="#text"&&o.textContent==="\uFEFF"&&o.remove()}}t.customElements.define("code-block",n)}function Vm(r,e){r.ui.registry.addIcon("codeblock",'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>'),r.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){r.execCommand("codeeditor")}}),r.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){r.execCommand("codeeditor")}}),r.addCommand("codeeditor",()=>{let t=r.selection.getNode(),n=t.ownerDocument;if(fd(t))pd(r,t);else{let i=r.selection.getContent({format:"text"});md(r,i,"",(s,o)=>{let a=n.createElement("pre"),l=n.createElement("code");l.classList.add(`language-${o}`),l.innerText=s,a.append(l),r.insertContent(a.outerHTML)})}}),r.on("dblclick",t=>{let n=r.selection.getNode();fd(n)&&pd(r,n)}),r.on("PreInit",()=>{r.parser.addNodeFilter("pre",function(t){for(let n of t){let i=tinymce.html.Node.create("code-block",{contenteditable:"false"}),s=n.getAll("span");for(let o of s)o.unwrap();n.attr("style",null),n.wrap(i)}}),r.parser.addNodeFilter("code-block",function(t){for(let n of t)n.attr("contenteditable","false")}),r.serializer.addNodeFilter("code-block",function(t){for(let n of t)n.unwrap()})}),r.ui.registry.addContextToolbar("codeeditor",{predicate:function(t){return t.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),r.on("PreInit",()=>{Hm(r)})}function gd(r){return Vm}var Et=null,yr=null,vr={};function Ns(r){return r.hasAttribute("drawio-diagram")}function qm(r,e=null){Et=r,yr=e,window.$components.first("image-manager").show(function(n){if(e){let i=e.querySelector("img");Et.undoManager.transact(function(){Et.dom.setAttrib(i,"src",n.url),Et.dom.setAttrib(e,"drawio-diagram",n.id)})}else{let i=`<div drawio-diagram="${n.id}" contenteditable="false"><img src="${n.url}"></div>`;Et.insertContent(i)}},"drawio")}function vd(r,e=null){Et=r,yr=e,kt.show(vr.drawioUrl,Wm,Gm)}async function Gm(r){let e="image-"+Math.random().toString(16).slice(2),t=window.baseUrl("/loading.gif"),n=i=>{i.status===413?window.$events.emit("error",vr.translations.serverUploadLimitText):window.$events.emit("error",vr.translations.imageUploadErrorText),console.log(i)};if(yr){kt.close();let i=yr.querySelector("img");try{let s=await kt.upload(r,vr.pageId);Et.undoManager.transact(function(){Et.dom.setAttrib(i,"src",s.url),Et.dom.setAttrib(yr,"drawio-diagram",s.id)})}catch(s){n(s)}return}setTimeout(async()=>{Et.insertContent(`<div drawio-diagram contenteditable="false"><img src="${t}" id="${e}"></div>`),kt.close();try{let i=await kt.upload(r,vr.pageId);Et.undoManager.transact(function(){Et.dom.setAttrib(e,"src",i.url),Et.dom.get(e).parentNode.setAttribute("drawio-diagram",i.id)})}catch(i){Et.dom.remove(e),n(i)}},5)}function Wm(){if(!yr)return Promise.resolve("");let r=yr.getAttribute("drawio-diagram");return kt.load(r)}function yd(r){return vr=r,function(e,t){e.addCommand("drawio",()=>{let n=e.selection.getNode();vd(e,Ns(n)?n:null)}),e.ui.registry.addIcon("diagram",`<svg width="24" height="24" fill="${vr.darkMode?"#BBB":"#000000"}" xmlns="http://www.w3.org/2000/svg"><path d="M20.716 7.639V2.845h-4.794v1.598h-7.99V2.845H3.138v4.794h1.598v7.99H3.138v4.794h4.794v-1.598h7.99v1.598h4.794v-4.794h-1.598v-7.99zM4.736 4.443h1.598V6.04H4.736zm1.598 14.382H4.736v-1.598h1.598zm9.588-1.598h-7.99v-1.598H6.334v-7.99h1.598V6.04h7.99v1.598h1.598v7.99h-1.598zm3.196 1.598H17.52v-1.598h1.598zM17.52 6.04V4.443h1.598V6.04zm-4.21 7.19h-2.79l-.582 1.599H8.643l2.717-7.191h1.119l2.724 7.19h-1.302zm-2.43-1.006h2.086l-1.039-3.06z"/></svg>`),e.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){e.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(n){n([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(n,i){if(i==="drawing-manager"){let s=e.selection.getNode();qm(e,Ns(s)?s:null)}}}),e.on("dblclick",n=>{let i=e.selection.getNode();Ns(i)&&vd(e,i)}),e.on("SetContent",function(){let n=e.dom.select("body > div[drawio-diagram]");n.length&&e.undoManager.transact(function(){for(let i of n)i.setAttribute("contenteditable","false")})})}}function Ym(r,e){r.addCommand("InsertHorizontalRule",function(){let t=document.createElement("hr"),n=r.selection.getNode();n.parentNode.insertBefore(t,n)}),r.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){r.execCommand("InsertHorizontalRule")}})}function bd(r){return Ym}function Km(r,e){r.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(function(n){let i=n.thumbs.display||n.url,s=`<a href="${n.url}" target="_blank">`;s+=`<img src="${i}" alt="${n.name}">`,s+="</a>",r.execCommand("mceInsertContent",!1,s)},"gallery")}})}function xd(r){return Km}function Xm(r,e){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/wysiwyg")};r.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){tinymce.activeEditor.windowManager.openUrl(t)}})}function wd(r){return Xm}var Ed=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table"];function Zm(r,e){r.ui.registry.addIcon("details",'<svg width="24" height="24"><path d="M8.2 9a.5.5 0 0 0-.4.8l4 5.6a.5.5 0 0 0 .8 0l4-5.6a.5.5 0 0 0-.4-.8ZM20.122 18.151h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7zM20.122 3.042h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7z"/></svg>'),r.ui.registry.addIcon("togglefold",'<svg height="24" width="24"><path d="M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z"/></svg>'),r.ui.registry.addIcon("togglelabel",'<svg height="18" width="18" viewBox="0 0 24 24"><path d="M21.41,11.41l-8.83-8.83C12.21,2.21,11.7,2,11.17,2H4C2.9,2,2,2.9,2,4v7.17c0,0.53,0.21,1.04,0.59,1.41l8.83,8.83 c0.78,0.78,2.05,0.78,2.83,0l7.17-7.17C22.2,13.46,22.2,12.2,21.41,11.41z M6.5,8C5.67,8,5,7.33,5,6.5S5.67,5,6.5,5S8,5.67,8,6.5 S7.33,8,6.5,8z"/></svg>'),r.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){r.execCommand("InsertDetailsBlock")}}),r.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){tg(r)}}),r.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Cd(r)}}),r.on("dblclick",t=>{!mo(r)||t.target.closest("doc-root")||Cd(r)}),r.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){mo(r).toggleAttribute("open"),r.focus()}}),r.addCommand("InsertDetailsBlock",function(){let t=r.selection.getContent({format:"html"}),n=document.createElement("details"),i=document.createElement("summary"),s="details-"+Date.now();n.setAttribute("data-id",s),n.appendChild(i),t||(t="<p><br></p>"),n.innerHTML+=t,r.insertContent(n.outerHTML),r.focus();let o=r.dom.select(`[data-id="${s}"]`)[0]||null;if(o){let a=o.querySelector("doc-root > *");a&&a.focus(),o.removeAttribute("data-id")}}),r.ui.registry.addContextToolbar("details",{predicate:function(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),r.on("PreInit",()=>{rg(r)})}function Cd(r){let e=mo(r);r.windowManager.open(Jm(r)).setData({summary:Qm(e)})}function mo(r){return r.selection.getNode().closest("details")}function Qm(r){let e=r.querySelector("summary");return e?e.textContent:""}function Jm(r){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(e){let{summary:t}=e.getData();eg(r,t),e.close()}}}function eg(r,e){let t=mo(r);t&&r.undoManager.transact(()=>{let n=t.querySelector("summary");n||(n=document.createElement("summary"),t.prepend(n)),n.textContent=e})}function tg(r){let e=r.selection.getNode().closest("details"),t=r.selection.getBookmark();if(e){let n=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");r.undoManager.transact(()=>{for(let i of n)e.parentNode.insertBefore(i,e);e.remove()})}r.focus(),r.selection.moveToBookmark(t)}function rg(r){r.parser.addNodeFilter("details",function(e){for(let t of e)ng(t)}),r.serializer.addNodeFilter("details",function(e){for(let t of e)Us(t),t.attr("open",null)}),r.serializer.addNodeFilter("doc-root",function(e){for(let t of e)t.unwrap()})}function ng(r){Us(r),r.attr("contenteditable","false");let e=tinymce.html.Node.create("doc-root",{contenteditable:"true"}),t=null;for(let n of r.children()){if(n.name==="summary")continue;Ed.includes(n.name)?(e.append(n),t=null):(t||(t=tinymce.html.Node.create("p"),e.append(t)),t.append(n))}r.append(e)}function Us(r){r.attr("contenteditable",null);let e=!1;for(let t of r.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&Us(r)}function Sd(r){return Zm}function ig(r,e){r.ui.registry.addIcon("tasklist",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22,8c0-0.55-0.45-1-1-1h-7c-0.55,0-1,0.45-1,1s0.45,1,1,1h7C21.55,9,22,8.55,22,8z M13,16c0,0.55,0.45,1,1,1h7 c0.55,0,1-0.45,1-1c0-0.55-0.45-1-1-1h-7C13.45,15,13,15.45,13,16z M10.47,4.63c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25 c-0.39,0.39-1.02,0.39-1.42,0L2.7,8.16c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0l1.42,1.42l3.54-3.54 C9.45,4.25,10.09,4.25,10.47,4.63z M10.48,12.64c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25c-0.39,0.39-1.02,0.39-1.42,0L2.7,16.16 c-0.39-0.39-0.39-1.02,0-1.41s1.02-0.39,1.41,0l1.42,1.42l3.54-3.54C9.45,12.25,10.09,12.25,10.48,12.64L10.48,12.64z"/></svg>'),r.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(i){i.isActive()?r.execCommand("RemoveList"):r.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(i){r.on("NodeChange",s=>{let o=s.parents.find(l=>l.nodeName==="LI"),a=o&&o.classList.contains("task-list-item");i.setActive(Boolean(a))})}});let t=r.ui.registry.getAll().buttons.bullist;t.onSetup=function(i){r.on("NodeChange",s=>{let o=s.parents.find(c=>c.nodeName==="LI"),a=o&&o.classList.contains("task-list-item"),l=o&&o.parentNode.nodeName==="UL";i.setActive(Boolean(l&&!a))})},t.onAction=function(){og(r.selection.getNode())&&r.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),r.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let n=r.ui.registry.getAll().buttons.numlist;n.onAction=function(){r.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},r.on("PreInit",()=>{r.parser.addNodeFilter("li",function(i){for(let s of i)s.attributes.map.class==="task-list-item"&&ag(s)}),r.serializer.addNodeFilter("li",function(i){for(let s of i)s.attributes.map.class==="task-list-item"&&lg(s)})}),r.on("click",function(i){let s=i.target;s.nodeName==="LI"&&s.classList.contains("task-list-item")&&(sg(i,s,r),i.preventDefault())})}function og(r){let e=r.closest("li");return e&&e.parentNode.nodeName==="UL"&&e.classList.contains("task-list-item")}function sg(r,e,t){let n=e.getBoundingClientRect();r.clientX<=n.right&&r.clientX>=n.left&&r.clientY>=n.top&&r.clientY<=n.bottom||t.undoManager.transact(()=>{e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","checked")})}function ag(r){r.attr("class","task-list-item");for(let e of r.children())e.name==="input"&&(e.attr("checked")==="checked"&&r.attr("checked","checked"),e.remove())}function lg(r){let e=r.attr("checked")==="checked";r.attr("checked",null);let t={type:"checkbox",disabled:"disabled"};e&&(t.checked="checked");let n=tinymce.html.Node.create("input",t);n.shortEnded=!0,r.firstChild?r.insert(n,r.firstChild,!0):r.append(n)}function Ad(r){return ig}var cg=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],ug={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},dg=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function hg(r,e,t){t.filetype==="file"&&window.$components.first("entity-selector-popup").show(i=>{r(i.link,{text:i.name,title:i.name})}),t.filetype==="image"&&window.$components.first("image-manager").show(function(i){r(i.url,{alt:i.name})},"gallery")}function fg(r){let e=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist",r.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",gd(r)),window.tinymce.PluginManager.add("customhr",bd(r)),window.tinymce.PluginManager.add("imagemanager",xd(r)),window.tinymce.PluginManager.add("about",wd(r)),window.tinymce.PluginManager.add("details",Sd(r)),window.tinymce.PluginManager.add("tasklist",Ad(r)),r.drawioUrl&&(window.tinymce.PluginManager.add("drawio",yd(r)),e.push("drawio")),e.filter(t=>Boolean(t))}function pg(){let r=document.head.innerHTML.split(`
+`};zt.text=function(r,e){return pr(r[e].content)};zt.html_block=function(r,e){return r[e].content};zt.html_inline=function(r,e){return r[e].content};function Lr(){this.rules=pf({},zt)}Lr.prototype.renderAttrs=function(e){var t,n,o;if(!e.attrs)return"";for(o="",t=0,n=e.attrs.length;t<n;t++)o+=" "+pr(e.attrs[t][0])+'="'+pr(e.attrs[t][1])+'"';return o};Lr.prototype.renderToken=function(e,t,n){var o,s="",i=!1,a=e[t];return a.hidden?"":(a.block&&a.nesting!==-1&&t&&e[t-1].hidden&&(s+=`
+`),s+=(a.nesting===-1?"</":"<")+a.tag,s+=this.renderAttrs(a),a.nesting===0&&n.xhtmlOut&&(s+=" /"),a.block&&(i=!0,a.nesting===1&&t+1<e.length&&(o=e[t+1],(o.type==="inline"||o.hidden||o.nesting===-1&&o.tag===a.tag)&&(i=!1))),s+=i?`>
+`:">",s)};Lr.prototype.renderInline=function(r,e,t){for(var n,o="",s=this.rules,i=0,a=r.length;i<a;i++)n=r[i].type,typeof s[n]<"u"?o+=s[n](r,i,e,t,this):o+=this.renderToken(r,i,e);return o};Lr.prototype.renderInlineAsText=function(r,e,t){for(var n="",o=0,s=r.length;o<s;o++)r[o].type==="text"?n+=r[o].content:r[o].type==="image"?n+=this.renderInlineAsText(r[o].children,e,t):r[o].type==="softbreak"&&(n+=`
+`);return n};Lr.prototype.render=function(r,e,t){var n,o,s,i="",a=this.rules;for(n=0,o=r.length;n<o;n++)s=r[n].type,s==="inline"?i+=this.renderInline(r[n].children,e,t):typeof a[s]<"u"?i+=a[r[n].type](r,n,e,t,this):i+=this.renderToken(r,n,e,t);return i};pl.exports=Lr});var Si=ne((Py,gl)=>{"use strict";function Mt(){this.__rules__=[],this.__cache__=null}Mt.prototype.__find__=function(r){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===r)return e;return-1};Mt.prototype.__compile__=function(){var r=this,e=[""];r.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n)})}),r.__cache__={},e.forEach(function(t){r.__cache__[t]=[],r.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||r.__cache__[t].push(n.fn))})})};Mt.prototype.at=function(r,e,t){var n=this.__find__(r),o=t||{};if(n===-1)throw new Error("Parser rule not found: "+r);this.__rules__[n].fn=e,this.__rules__[n].alt=o.alt||[],this.__cache__=null};Mt.prototype.before=function(r,e,t,n){var o=this.__find__(r),s=n||{};if(o===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(o,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};Mt.prototype.after=function(r,e,t,n){var o=this.__find__(r),s=n||{};if(o===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(o+1,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};Mt.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null};Mt.prototype.enable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var o=this.__find__(n);if(o<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[o].enabled=!0,t.push(n)},this),this.__cache__=null,t};Mt.prototype.enableOnly=function(r,e){Array.isArray(r)||(r=[r]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(r,e)};Mt.prototype.disable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var o=this.__find__(n);if(o<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[o].enabled=!1,t.push(n)},this),this.__cache__=null,t};Mt.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[]};gl.exports=Mt});var yl=ne((My,vl)=>{"use strict";var gf=/\r\n?|\n/g,vf=/\0/g;vl.exports=function(e){var t;t=e.src.replace(gf,`
+`),t=t.replace(vf,"\uFFFD"),e.src=t}});var xl=ne(($y,bl)=>{"use strict";bl.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 Cl=ne((_y,wl)=>{"use strict";wl.exports=function(e){var t=e.tokens,n,o,s;for(o=0,s=t.length;o<s;o++)n=t[o],n.type==="inline"&&e.md.inline.parse(n.content,e.md,e.env,n.children)}});var Sl=ne((By,El)=>{"use strict";var yf=Be().arrayReplaceAt;function bf(r){return/^<a[>\s]/i.test(r)}function xf(r){return/^<\/a\s*>/i.test(r)}El.exports=function(e){var t,n,o,s,i,a,l,c,u,d,h,f,p,v,y,b,x=e.tokens,T;if(e.md.options.linkify){for(n=0,o=x.length;n<o;n++)if(!(x[n].type!=="inline"||!e.md.linkify.pretest(x[n].content)))for(s=x[n].children,p=0,t=s.length-1;t>=0;t--){if(a=s[t],a.type==="link_close"){for(t--;s[t].level!==a.level&&s[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(bf(a.content)&&p>0&&p--,xf(a.content)&&p++),!(p>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,T=e.md.linkify.match(u),l=[],f=a.level,h=0,T.length>0&&T[0].index===0&&t>0&&s[t-1].type==="text_special"&&(T=T.slice(1)),c=0;c<T.length;c++)v=T[c].url,y=e.md.normalizeLink(v),e.md.validateLink(y)&&(b=T[c].text,T[c].schema?T[c].schema==="mailto:"&&!/^mailto:/i.test(b)?b=e.md.normalizeLinkText("mailto:"+b).replace(/^mailto:/,""):b=e.md.normalizeLinkText(b):b=e.md.normalizeLinkText("http://"+b).replace(/^http:\/\//,""),d=T[c].index,d>h&&(i=new e.Token("text","",0),i.content=u.slice(h,d),i.level=f,l.push(i)),i=new e.Token("link_open","a",1),i.attrs=[["href",y]],i.level=f++,i.markup="linkify",i.info="auto",l.push(i),i=new e.Token("text","",0),i.content=b,i.level=f,l.push(i),i=new e.Token("link_close","a",-1),i.level=--f,i.markup="linkify",i.info="auto",l.push(i),h=T[c].lastIndex);h<u.length&&(i=new e.Token("text","",0),i.content=u.slice(h),i.level=f,l.push(i)),x[n].children=s=yf(s,t,l)}}}}});var Tl=ne((Ny,kl)=>{"use strict";var Al=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,wf=/\((c|tm|r)\)/i,Cf=/\((c|tm|r)\)/ig,Ef={c:"\xA9",r:"\xAE",tm:"\u2122"};function Sf(r,e){return Ef[e.toLowerCase()]}function Af(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&(t.content=t.content.replace(Cf,Sf)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function kf(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&Al.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++}kl.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(wf.test(e.tokens[t].content)&&Af(e.tokens[t].children),Al.test(e.tokens[t].content)&&kf(e.tokens[t].children))}});var Pl=ne((Uy,Ol)=>{"use strict";var Il=Be().isWhiteSpace,Dl=Be().isPunctChar,Ll=Be().isMdAsciiPunct,Tf=/['"]/,Fl=/['"]/g,Rl="\u2019";function Ai(r,e,t){return r.slice(0,e)+t+r.slice(e+1)}function If(r,e){var t,n,o,s,i,a,l,c,u,d,h,f,p,v,y,b,x,T,C,M,S;for(C=[],t=0;t<r.length;t++){for(n=r[t],l=r[t].level,x=C.length-1;x>=0&&!(C[x].level<=l);x--);if(C.length=x+1,n.type!=="text")continue;o=n.content,i=0,a=o.length;e:for(;i<a&&(Fl.lastIndex=i,s=Fl.exec(o),!!s);){if(y=b=!0,i=s.index+1,T=s[0]==="'",u=32,s.index-1>=0)u=o.charCodeAt(s.index-1);else for(x=t-1;x>=0&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x--)if(r[x].content){u=r[x].content.charCodeAt(r[x].content.length-1);break}if(d=32,i<a)d=o.charCodeAt(i);else for(x=t+1;x<r.length&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x++)if(r[x].content){d=r[x].content.charCodeAt(0);break}if(h=Ll(u)||Dl(String.fromCharCode(u)),f=Ll(d)||Dl(String.fromCharCode(d)),p=Il(u),v=Il(d),v?y=!1:f&&(p||h||(y=!1)),p?b=!1:h&&(v||f||(b=!1)),d===34&&s[0]==='"'&&u>=48&&u<=57&&(b=y=!1),y&&b&&(y=h,b=f),!y&&!b){T&&(n.content=Ai(n.content,s.index,Rl));continue}if(b){for(x=C.length-1;x>=0&&(c=C[x],!(C[x].level<l));x--)if(c.single===T&&C[x].level===l){c=C[x],T?(M=e.md.options.quotes[2],S=e.md.options.quotes[3]):(M=e.md.options.quotes[0],S=e.md.options.quotes[1]),n.content=Ai(n.content,s.index,S),r[c.token].content=Ai(r[c.token].content,c.pos,M),i+=S.length-1,c.token===t&&(i+=M.length-1),o=n.content,a=o.length,C.length=x;continue e}}y?C.push({token:t,pos:s.index,single:T,level:l}):b&&T&&(n.content=Ai(n.content,s.index,Rl))}}}Ol.exports=function(e){var t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!Tf.test(e.tokens[t].content)||If(e.tokens[t].children,e)}});var $l=ne((zy,Ml)=>{"use strict";Ml.exports=function(e){var t,n,o,s,i,a,l=e.tokens;for(t=0,n=l.length;t<n;t++)if(l[t].type==="inline"){for(o=l[t].children,i=o.length,s=0;s<i;s++)o[s].type==="text_special"&&(o[s].type="text");for(s=a=0;s<i;s++)o[s].type==="text"&&s+1<i&&o[s+1].type==="text"?o[s+1].content=o[s].content+o[s+1].content:(s!==a&&(o[a]=o[s]),a++);s!==a&&(o.length=a)}}});var ki=ne((jy,_l)=>{"use strict";function Fr(r,e,t){this.type=r,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}Fr.prototype.attrIndex=function(e){var t,n,o;if(!this.attrs)return-1;for(t=this.attrs,n=0,o=t.length;n<o;n++)if(t[n][0]===e)return n;return-1};Fr.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Fr.prototype.attrSet=function(e,t){var n=this.attrIndex(e),o=[e,t];n<0?this.attrPush(o):this.attrs[n]=o};Fr.prototype.attrGet=function(e){var t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n};Fr.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};_l.exports=Fr});var Ul=ne((Hy,Nl)=>{"use strict";var Df=ki();function Bl(r,e,t){this.src=r,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Bl.prototype.Token=Df;Nl.exports=Bl});var jl=ne((Vy,zl)=>{"use strict";var Lf=Si(),ns=[["normalize",yl()],["block",xl()],["inline",Cl()],["linkify",Sl()],["replacements",Tl()],["smartquotes",Pl()],["text_join",$l()]];function is(){this.ruler=new Lf;for(var r=0;r<ns.length;r++)this.ruler.push(ns[r][0],ns[r][1])}is.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r)};is.prototype.State=Ul();zl.exports=is});var ql=ne((qy,Vl)=>{"use strict";var os=Be().isSpace;function ss(r,e){var t=r.bMarks[e]+r.tShift[e],n=r.eMarks[e];return r.src.slice(t,n)}function Hl(r){var e=[],t=0,n=r.length,o,s=!1,i=0,a="";for(o=r.charCodeAt(t);t<n;)o===124&&(s?(a+=r.substring(i,t-1),i=t):(e.push(a+r.substring(i,t)),a="",i=t+1)),s=o===92,t++,o=r.charCodeAt(t);return e.push(a+r.substring(i)),e}Vl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,T,C,M,S;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])||(M=e.src.charCodeAt(a++),M!==124&&M!==45&&M!==58)||a>=e.eMarks[u]||(S=e.src.charCodeAt(a++),S!==124&&S!==45&&S!==58&&!os(S))||M===45&&os(S))return!1;for(;a<e.eMarks[u];){if(s=e.src.charCodeAt(a),s!==124&&s!==45&&s!==58&&!os(s))return!1;a++}for(i=ss(e,t+1),d=i.split("|"),p=[],l=0;l<d.length;l++){if(v=d[l].trim(),!v){if(l===0||l===d.length-1)continue;return!1}if(!/^:?-+:?$/.test(v))return!1;v.charCodeAt(v.length-1)===58?p.push(v.charCodeAt(0)===58?"center":"right"):v.charCodeAt(0)===58?p.push("left"):p.push("")}if(i=ss(e,t).trim(),i.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(d=Hl(i),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),h=d.length,h===0||h!==p.length))return!1;if(o)return!0;for(x=e.parentType,e.parentType="table",C=e.md.block.ruler.getRules("blockquote"),f=e.push("table_open","table",1),f.map=y=[t,0],f=e.push("thead_open","thead",1),f.map=[t,t+1],f=e.push("tr_open","tr",1),f.map=[t,t+1],l=0;l<d.length;l++)f=e.push("th_open","th",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l].trim(),f.children=[],f=e.push("th_close","th",-1);for(f=e.push("tr_close","tr",-1),f=e.push("thead_close","thead",-1),u=t+2;u<n&&!(e.sCount[u]<e.blkIndent);u++){for(T=!1,l=0,c=C.length;l<c;l++)if(C[l](e,u,n,!0)){T=!0;break}if(T||(i=ss(e,u).trim(),!i)||e.sCount[u]-e.blkIndent>=4)break;for(d=Hl(i),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),u===t+2&&(f=e.push("tbody_open","tbody",1),f.map=b=[t+2,0]),f=e.push("tr_open","tr",1),f.map=[u,u+1],l=0;l<h;l++)f=e.push("td_open","td",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l]?d[l].trim():"",f.children=[],f=e.push("td_close","td",-1);f=e.push("tr_close","tr",-1)}return b&&(f=e.push("tbody_close","tbody",-1),b[1]=u),f=e.push("table_close","table",-1),y[1]=u,e.parentType=x,e.line=u,!0}});var Wl=ne((Gy,Gl)=>{"use strict";Gl.exports=function(e,t,n){var o,s,i;if(e.sCount[t]-e.blkIndent<4)return!1;for(s=o=t+1;o<n;){if(e.isEmpty(o)){o++;continue}if(e.sCount[o]-e.blkIndent>=4){o++,s=o;continue}break}return e.line=s,i=e.push("code_block","code",0),i.content=e.getLines(t,s,4+e.blkIndent,!1)+`
+`,i.map=[t,e.line],!0}});var Kl=ne((Wy,Yl)=>{"use strict";Yl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h=!1,f=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||f+3>p||(s=e.src.charCodeAt(f),s!==126&&s!==96)||(c=f,f=e.skipChars(f,s),i=f-c,i<3)||(d=e.src.slice(c,f),a=e.src.slice(f,p),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(o)return!0;for(l=t;l++,!(l>=n||(f=c=e.bMarks[l]+e.tShift[l],p=e.eMarks[l],f<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(f)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(f=e.skipChars(f,s),!(f-c<i)&&(f=e.skipSpaces(f),!(f<p)))){h=!0;break}return i=e.sCount[t],e.line=l+(h?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,i,!0),u.markup=d,u.map=[t,e.line],!0}});var Ql=ne((Yy,Zl)=>{"use strict";var Xl=Be().isSpace;Zl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,T,C,M,S,O,A,D=e.lineMax,I=e.bMarks[t]+e.tShift[t],P=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(I++)!==62)return!1;if(o)return!0;for(l=f=e.sCount[t]+1,e.src.charCodeAt(I)===32?(I++,l++,f++,s=!1,C=!0):e.src.charCodeAt(I)===9?(C=!0,(e.bsCount[t]+f)%4===3?(I++,l++,f++,s=!1):s=!0):C=!1,p=[e.bMarks[t]],e.bMarks[t]=I;I<P&&(i=e.src.charCodeAt(I),Xl(i));){i===9?f+=4-(f+e.bsCount[t]+(s?1:0))%4:f++;I++}for(v=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(C?1:0),u=I>=P,x=[e.sCount[t]],e.sCount[t]=f-l,T=[e.tShift[t]],e.tShift[t]=I-e.bMarks[t],S=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",h=t+1;h<n&&(A=e.sCount[h]<e.blkIndent,I=e.bMarks[h]+e.tShift[h],P=e.eMarks[h],!(I>=P));h++){if(e.src.charCodeAt(I++)===62&&!A){for(l=f=e.sCount[h]+1,e.src.charCodeAt(I)===32?(I++,l++,f++,s=!1,C=!0):e.src.charCodeAt(I)===9?(C=!0,(e.bsCount[h]+f)%4===3?(I++,l++,f++,s=!1):s=!0):C=!1,p.push(e.bMarks[h]),e.bMarks[h]=I;I<P&&(i=e.src.charCodeAt(I),Xl(i));){i===9?f+=4-(f+e.bsCount[h]+(s?1:0))%4:f++;I++}u=I>=P,v.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(C?1:0),x.push(e.sCount[h]),e.sCount[h]=f-l,T.push(e.tShift[h]),e.tShift[h]=I-e.bMarks[h];continue}if(u)break;for(M=!1,a=0,c=S.length;a<c;a++)if(S[a](e,h,n,!0)){M=!0;break}if(M){e.lineMax=h,e.blkIndent!==0&&(p.push(e.bMarks[h]),v.push(e.bsCount[h]),T.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}p.push(e.bMarks[h]),v.push(e.bsCount[h]),T.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]=-1}for(y=e.blkIndent,e.blkIndent=0,O=e.push("blockquote_open","blockquote",1),O.markup=">",O.map=d=[t,0],e.md.block.tokenize(e,t,h),O=e.push("blockquote_close","blockquote",-1),O.markup=">",e.lineMax=D,e.parentType=b,d[1]=e.line,a=0;a<T.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=T[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=v[a];return e.blkIndent=y,!0}});var ec=ne((Ky,Jl)=>{"use strict";var Ff=Be().isSpace;Jl.exports=function(e,t,n,o){var s,i,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c++),s!==42&&s!==45&&s!==95))return!1;for(i=1;c<u;){if(a=e.src.charCodeAt(c++),a!==s&&!Ff(a))return!1;a===s&&i++}return i<3?!1:(o||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(i+1).join(String.fromCharCode(s))),!0)}});var oc=ne((Xy,ic)=>{"use strict";var nc=Be().isSpace;function tc(r,e){var t,n,o,s;return n=r.bMarks[e]+r.tShift[e],o=r.eMarks[e],t=r.src.charCodeAt(n++),t!==42&&t!==45&&t!==43||n<o&&(s=r.src.charCodeAt(n),!nc(s))?-1:n}function rc(r,e){var t,n=r.bMarks[e]+r.tShift[e],o=n,s=r.eMarks[e];if(o+1>=s||(t=r.src.charCodeAt(o++),t<48||t>57))return-1;for(;;){if(o>=s)return-1;if(t=r.src.charCodeAt(o++),t>=48&&t<=57){if(o-n>=10)return-1;continue}if(t===41||t===46)break;return-1}return o<s&&(t=r.src.charCodeAt(o),!nc(t))?-1:o}function Rf(r,e){var t,n,o=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===o&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].hidden=!0,r.tokens[t].hidden=!0,t+=2)}ic.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,T,C,M,S,O,A,D,I,P,_,B,H,Q,Y,re=!1,ie=!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(o&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(re=!0),(P=rc(e,t))>=0){if(d=!0,B=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(B,P-1)),re&&b!==1)return!1}else if((P=tc(e,t))>=0)d=!1;else return!1;if(re&&e.skipSpaces(P)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(P-1),o)return!0;for(v=e.tokens.length,d?(Y=e.push("ordered_list_open","ol",1),b!==1&&(Y.attrs=[["start",b]])):Y=e.push("bullet_list_open","ul",1),Y.map=p=[t,0],Y.markup=String.fromCharCode(y),T=t,_=!1,Q=e.md.block.ruler.getRules("list"),S=e.parentType,e.parentType="list";T<n;){for(I=P,x=e.eMarks[T],u=C=e.sCount[T]+P-(e.bMarks[t]+e.tShift[t]);I<x;){if(s=e.src.charCodeAt(I),s===9)C+=4-(C+e.bsCount[T])%4;else if(s===32)C++;else break;I++}if(i=I,i>=x?c=1:c=C-u,c>4&&(c=1),l=u+c,Y=e.push("list_item_open","li",1),Y.markup=String.fromCharCode(y),Y.map=h=[t,0],d&&(Y.info=e.src.slice(B,P-1)),D=e.tight,A=e.tShift[t],O=e.sCount[t],M=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=i-e.bMarks[t],e.sCount[t]=C,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||_)&&(ie=!1),_=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=M,e.tShift[t]=A,e.sCount[t]=O,e.tight=D,Y=e.push("list_item_close","li",-1),Y.markup=String.fromCharCode(y),T=t=e.line,h[1]=T,i=e.bMarks[t],T>=n||e.sCount[T]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(H=!1,a=0,f=Q.length;a<f;a++)if(Q[a](e,T,n,!0)){H=!0;break}if(H)break;if(d){if(P=rc(e,T),P<0)break;B=e.bMarks[T]+e.tShift[T]}else if(P=tc(e,T),P<0)break;if(y!==e.src.charCodeAt(P-1))break}return d?Y=e.push("ordered_list_close","ol",-1):Y=e.push("bullet_list_close","ul",-1),Y.markup=String.fromCharCode(y),p[1]=T,e.line=T,e.parentType=S,ie&&Rf(e,v),!0}});var ac=ne((Zy,sc)=>{"use strict";var Of=Be().normalizeReference,Ti=Be().isSpace;sc.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,T,C,M=0,S=e.bMarks[t]+e.tShift[t],O=e.eMarks[t],A=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(S)!==91)return!1;for(;++S<O;)if(e.src.charCodeAt(S)===93&&e.src.charCodeAt(S-1)!==92){if(S+1===O||e.src.charCodeAt(S+1)!==58)return!1;break}for(l=e.lineMax,T=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";A<l&&!e.isEmpty(A);A++)if(!(e.sCount[A]-e.blkIndent>3)&&!(e.sCount[A]<0)){for(x=!1,u=0,d=T.length;u<d;u++)if(T[u](e,A,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,A,e.blkIndent,!1).trim(),O=b.length,S=1;S<O;S++){if(s=b.charCodeAt(S),s===91)return!1;if(s===93){f=S;break}else s===10?M++:s===92&&(S++,S<O&&b.charCodeAt(S)===10&&M++)}if(f<0||b.charCodeAt(f+1)!==58)return!1;for(S=f+2;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!Ti(s))break;if(v=e.md.helpers.parseLinkDestination(b,S,O),!v.ok||(c=e.md.normalizeLink(v.str),!e.md.validateLink(c)))return!1;for(S=v.pos,M+=v.lines,i=S,a=M,y=S;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!Ti(s))break;for(v=e.md.helpers.parseLinkTitle(b,S,O),S<O&&y!==S&&v.ok?(C=v.str,S=v.pos,M+=v.lines):(C="",S=i,M=a);S<O&&(s=b.charCodeAt(S),!!Ti(s));)S++;if(S<O&&b.charCodeAt(S)!==10&&C)for(C="",S=i,M=a;S<O&&(s=b.charCodeAt(S),!!Ti(s));)S++;return S<O&&b.charCodeAt(S)!==10||(h=Of(b.slice(1,f)),!h)?!1:(o||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[h]>"u"&&(e.env.references[h]={title:C,href:c}),e.parentType=p,e.line=t+M+1),!0)}});var cc=ne((Qy,lc)=>{"use strict";lc.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 ls=ne((Jy,as)=>{"use strict";var Pf="[a-zA-Z_:][a-zA-Z0-9:._-]*",Mf="[^\"'=<>`\\x00-\\x20]+",$f="'[^']*'",_f='"[^"]*"',Bf="(?:"+Mf+"|"+$f+"|"+_f+")",Nf="(?:\\s+"+Pf+"(?:\\s*=\\s*"+Bf+")?)",uc="<[A-Za-z][A-Za-z0-9\\-]*"+Nf+"*\\s*\\/?>",dc="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Uf="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",zf="<[?][\\s\\S]*?[?]>",jf="<![A-Z]+\\s+[^>]*>",Hf="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Vf=new RegExp("^(?:"+uc+"|"+dc+"|"+Uf+"|"+zf+"|"+jf+"|"+Hf+")"),qf=new RegExp("^(?:"+uc+"|"+dc+")");as.exports.HTML_TAG_RE=Vf;as.exports.HTML_OPEN_CLOSE_TAG_RE=qf});var fc=ne((e0,hc)=>{"use strict";var Gf=cc(),Wf=ls().HTML_OPEN_CLOSE_TAG_RE,Rr=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Gf.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Wf.source+"\\s*$"),/^$/,!1]];hc.exports=function(e,t,n,o){var s,i,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),s=0;s<Rr.length&&!Rr[s][0].test(l);s++);if(s===Rr.length)return!1;if(o)return Rr[s][2];if(i=t+1,!Rr[s][1].test(l)){for(;i<n&&!(e.sCount[i]<e.blkIndent);i++)if(c=e.bMarks[i]+e.tShift[i],u=e.eMarks[i],l=e.src.slice(c,u),Rr[s][1].test(l)){l.length!==0&&i++;break}}return e.line=i,a=e.push("html_block","",0),a.map=[t,i],a.content=e.getLines(t,i,e.blkIndent,!0),!0}});var gc=ne((t0,mc)=>{"use strict";var pc=Be().isSpace;mc.exports=function(e,t,n,o){var s,i,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c),s!==35||c>=u))return!1;for(i=1,s=e.src.charCodeAt(++c);s===35&&c<u&&i<=6;)i++,s=e.src.charCodeAt(++c);return i>6||c<u&&!pc(s)?!1:(o||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&pc(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(i),1),l.markup="########".slice(0,i),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(i),-1),l.markup="########".slice(0,i)),!0)}});var yc=ne((r0,vc)=>{"use strict";vc.exports=function(e,t,n){var o,s,i,a,l,c,u,d,h,f=t+1,p,v=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";f<n&&!e.isEmpty(f);f++)if(!(e.sCount[f]-e.blkIndent>3)){if(e.sCount[f]>=e.blkIndent&&(c=e.bMarks[f]+e.tShift[f],u=e.eMarks[f],c<u&&(h=e.src.charCodeAt(c),(h===45||h===61)&&(c=e.skipChars(c,h),c=e.skipSpaces(c),c>=u)))){d=h===61?1:2;break}if(!(e.sCount[f]<0)){for(s=!1,i=0,a=v.length;i<a;i++)if(v[i](e,f,n,!0)){s=!0;break}if(s)break}}return d?(o=e.getLines(t,f,e.blkIndent,!1).trim(),e.line=f+1,l=e.push("heading_open","h"+String(d),1),l.markup=String.fromCharCode(h),l.map=[t,e.line],l=e.push("inline","",0),l.content=o,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(d),-1),l.markup=String.fromCharCode(h),e.parentType=p,!0):!1}});var xc=ne((n0,bc)=>{"use strict";bc.exports=function(e,t){var n,o,s,i,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),d=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<d&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(o=!1,s=0,i=u.length;s<i;s++)if(u[s](e,c,d,!0)){o=!0;break}if(o)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 Ec=ne((i0,Cc)=>{"use strict";var wc=ki(),Ii=Be().isSpace;function jt(r,e,t,n){var o,s,i,a,l,c,u,d;for(this.src=r,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="",s=this.src,d=!1,i=a=c=u=0,l=s.length;a<l;a++){if(o=s.charCodeAt(a),!d)if(Ii(o)){c++,o===9?u+=4-u%4:u++;continue}else d=!0;(o===10||a===l-1)&&(o!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),d=!1,c=0,u=0,i=a+1)}this.bMarks.push(s.length),this.eMarks.push(s.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}jt.prototype.push=function(r,e,t){var n=new wc(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};jt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};jt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};jt.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!Ii(t));e++);return e};jt.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!Ii(this.src.charCodeAt(--e)))return e+1;return e};jt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};jt.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};jt.prototype.getLines=function(e,t,n,o){var s,i,a,l,c,u,d,h=e;if(e>=t)return"";for(u=new Array(t-e),s=0;h<t;h++,s++){for(i=0,d=l=this.bMarks[h],h+1<t||o?c=this.eMarks[h]+1:c=this.eMarks[h];l<c&&i<n;){if(a=this.src.charCodeAt(l),Ii(a))a===9?i+=4-(i+this.bsCount[h])%4:i++;else if(l-d<this.tShift[h])i++;else break;l++}i>n?u[s]=new Array(i-n+1).join(" ")+this.src.slice(l,c):u[s]=this.src.slice(l,c)}return u.join("")};jt.prototype.Token=wc;Cc.exports=jt});var Ac=ne((o0,Sc)=>{"use strict";var Yf=Si(),Di=[["table",ql(),["paragraph","reference"]],["code",Wl()],["fence",Kl(),["paragraph","reference","blockquote","list"]],["blockquote",Ql(),["paragraph","reference","blockquote","list"]],["hr",ec(),["paragraph","reference","blockquote","list"]],["list",oc(),["paragraph","reference","blockquote"]],["reference",ac()],["html_block",fc(),["paragraph","reference","blockquote"]],["heading",gc(),["paragraph","reference","blockquote"]],["lheading",yc()],["paragraph",xc()]];function Li(){this.ruler=new Yf;for(var r=0;r<Di.length;r++)this.ruler.push(Di[r][0],Di[r][1],{alt:(Di[r][2]||[]).slice()})}Li.prototype.tokenize=function(r,e,t){for(var n,o,s=this.ruler.getRules(""),i=s.length,a=e,l=!1,c=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=c){r.line=t;break}for(o=0;o<i&&(n=s[o](r,a,t,!1),!n);o++);r.tight=!l,r.isEmpty(r.line-1)&&(l=!0),a=r.line,a<t&&r.isEmpty(a)&&(l=!0,a++,r.line=a)}};Li.prototype.parse=function(r,e,t,n){var o;r&&(o=new this.State(r,e,t,n),this.tokenize(o,o.line,o.lineMax))};Li.prototype.State=Ec();Sc.exports=Li});var Tc=ne((s0,kc)=>{"use strict";function Kf(r){switch(r){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}}kc.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!Kf(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var Dc=ne((a0,Ic)=>{"use strict";var Xf=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;Ic.exports=function(e,t){var n,o,s,i,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(n=e.pos,o=e.posMax,n+3>o)||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47||(s=e.pending.match(Xf),!s)||(i=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-i.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,-i.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-i.length,!0)}});var Fc=ne((l0,Lc)=>{"use strict";var Zf=Be().isSpace;Lc.exports=function(e,t){var n,o,s,i=e.pos;if(e.src.charCodeAt(i)!==10)return!1;if(n=e.pending.length-1,o=e.posMax,!t)if(n>=0&&e.pending.charCodeAt(n)===32)if(n>=1&&e.pending.charCodeAt(n-1)===32){for(s=n-1;s>=1&&e.pending.charCodeAt(s-1)===32;)s--;e.pending=e.pending.slice(0,s),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(i++;i<o&&Zf(e.src.charCodeAt(i));)i++;return e.pos=i,!0}});var Oc=ne((c0,Rc)=>{"use strict";var Qf=Be().isSpace,us=[];for(cs=0;cs<256;cs++)us.push(0);var cs;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){us[r.charCodeAt(0)]=1});Rc.exports=function(e,t){var n,o,s,i,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),!!Qf(n));)l++;return e.pos=l,!0}return i=e.src[l],n>=55296&&n<=56319&&l+1<c&&(o=e.src.charCodeAt(l+1),o>=56320&&o<=57343&&(i+=e.src[l+1],l++)),s="\\"+i,t||(a=e.push("text_special","",0),n<256&&us[n]!==0?a.content=i:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var Mc=ne((u0,Pc)=>{"use strict";Pc.exports=function(e,t){var n,o,s,i,a,l,c,u,d=e.pos,h=e.src.charCodeAt(d);if(h!==96)return!1;for(n=d,d++,o=e.posMax;d<o&&e.src.charCodeAt(d)===96;)d++;if(s=e.src.slice(n,d),c=s.length,e.backticksScanned&&(e.backticks[c]||0)<=n)return t||(e.pending+=s),e.pos+=c,!0;for(a=l=d;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<o&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(i=e.push("code_inline","code",0),i.markup=s,i.content=e.src.slice(d,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=c,!0}});var hs=ne((d0,ds)=>{"use strict";ds.exports.tokenize=function(e,t){var n,o,s,i,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(o=e.scanDelims(e.pos,!0),i=o.length,a=String.fromCharCode(c),i<2))return!1;for(i%2&&(s=e.push("text","",0),s.content=a,i--),n=0;n<i;n+=2)s=e.push("text","",0),s.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function $c(r,e){var t,n,o,s,i,a=[],l=e.length;for(t=0;t<l;t++)o=e[t],o.marker===126&&o.end!==-1&&(s=e[o.end],i=r.tokens[o.token],i.type="s_open",i.tag="s",i.nesting=1,i.markup="~~",i.content="",i=r.tokens[s.token],i.type="s_close",i.tag="s",i.nesting=-1,i.markup="~~",i.content="",r.tokens[s.token-1].type==="text"&&r.tokens[s.token-1].content==="~"&&a.push(s.token-1));for(;a.length;){for(t=a.pop(),n=t+1;n<r.tokens.length&&r.tokens[n].type==="s_close";)n++;n--,t!==n&&(i=r.tokens[n],r.tokens[n]=r.tokens[t],r.tokens[t]=i)}}ds.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for($c(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&$c(e,n[t].delimiters)}});var ps=ne((h0,fs)=>{"use strict";fs.exports.tokenize=function(e,t){var n,o,s,i=e.pos,a=e.src.charCodeAt(i);if(t||a!==95&&a!==42)return!1;for(o=e.scanDelims(e.pos,a===42),n=0;n<o.length;n++)s=e.push("text","",0),s.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:o.length,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function _c(r,e){var t,n,o,s,i,a,l=e.length;for(t=l-1;t>=0;t--)n=e[t],!(n.marker!==95&&n.marker!==42)&&n.end!==-1&&(o=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===o.token+1,i=String.fromCharCode(n.marker),s=r.tokens[n.token],s.type=a?"strong_open":"em_open",s.tag=a?"strong":"em",s.nesting=1,s.markup=a?i+i:i,s.content="",s=r.tokens[o.token],s.type=a?"strong_close":"em_close",s.tag=a?"strong":"em",s.nesting=-1,s.markup=a?i+i:i,s.content="",a&&(r.tokens[e[t-1].token].content="",r.tokens[e[n.end+1].token].content="",t--))}fs.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(_c(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&_c(e,n[t].delimiters)}});var Nc=ne((f0,Bc)=>{"use strict";var Jf=Be().normalizeReference,ms=Be().isSpace;Bc.exports=function(e,t){var n,o,s,i,a,l,c,u,d,h="",f="",p=e.pos,v=e.posMax,y=e.pos,b=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,i=e.md.helpers.parseLinkLabel(e,e.pos,!0),i<0))return!1;if(l=i+1,l<v&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<v&&(o=e.src.charCodeAt(l),!(!ms(o)&&o!==10));l++);if(l>=v)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(h=e.md.normalizeLink(c.str),e.md.validateLink(h)?l=c.pos:h="",y=l;l<v&&(o=e.src.charCodeAt(l),!(!ms(o)&&o!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<v&&y!==l&&c.ok)for(f=c.str,l=c.pos;l<v&&(o=e.src.charCodeAt(l),!(!ms(o)&&o!==10));l++);}(l>=v||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<v&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(y,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),u=e.env.references[Jf(s)],!u)return e.pos=p,!1;h=u.href,f=u.title}return t||(e.pos=a,e.posMax=i,d=e.push("link_open","a",1),d.attrs=n=[["href",h]],f&&n.push(["title",f]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,d=e.push("link_close","a",-1)),e.pos=l,e.posMax=v,!0}});var zc=ne((p0,Uc)=>{"use strict";var ep=Be().normalizeReference,gs=Be().isSpace;Uc.exports=function(e,t){var n,o,s,i,a,l,c,u,d,h,f,p,v,y="",b=e.pos,x=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<x&&e.src.charCodeAt(c)===40){for(c++;c<x&&(o=e.src.charCodeAt(c),!(!gs(o)&&o!==10));c++);if(c>=x)return!1;for(v=c,d=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),d.ok&&(y=e.md.normalizeLink(d.str),e.md.validateLink(y)?c=d.pos:y=""),v=c;c<x&&(o=e.src.charCodeAt(c),!(!gs(o)&&o!==10));c++);if(d=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<x&&v!==c&&d.ok)for(h=d.str,c=d.pos;c<x&&(o=e.src.charCodeAt(c),!(!gs(o)&&o!==10));c++);else h="";if(c>=x||e.src.charCodeAt(c)!==41)return e.pos=b,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<x&&e.src.charCodeAt(c)===91?(v=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?i=e.src.slice(v,c++):c=a+1):c=a+1,i||(i=e.src.slice(l,a)),u=e.env.references[ep(i)],!u)return e.pos=b,!1;y=u.href,h=u.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),f=e.push("image","img",0),f.attrs=n=[["src",y],["alt",""]],f.children=p,f.content=s,h&&n.push(["title",h])),e.pos=c,e.posMax=x,!0}});var Hc=ne((m0,jc)=>{"use strict";var tp=/^([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])?)*)$/,rp=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;jc.exports=function(e,t){var n,o,s,i,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(i=e.src.charCodeAt(c),i===60))return!1;if(i===62)break}return n=e.src.slice(a+1,c),rp.test(n)?(o=e.md.normalizeLink(n),e.md.validateLink(o)?(t||(s=e.push("link_open","a",1),s.attrs=[["href",o]],s.markup="autolink",s.info="auto",s=e.push("text","",0),s.content=e.md.normalizeLinkText(n),s=e.push("link_close","a",-1),s.markup="autolink",s.info="auto"),e.pos+=n.length+2,!0):!1):tp.test(n)?(o=e.md.normalizeLink("mailto:"+n),e.md.validateLink(o)?(t||(s=e.push("link_open","a",1),s.attrs=[["href",o]],s.markup="autolink",s.info="auto",s=e.push("text","",0),s.content=e.md.normalizeLinkText(n),s=e.push("link_close","a",-1),s.markup="autolink",s.info="auto"),e.pos+=n.length+2,!0):!1):!1}});var qc=ne((g0,Vc)=>{"use strict";var np=ls().HTML_TAG_RE;function ip(r){return/^<a[>\s]/i.test(r)}function op(r){return/^<\/a\s*>/i.test(r)}function sp(r){var e=r|32;return e>=97&&e<=122}Vc.exports=function(e,t){var n,o,s,i,a=e.pos;return!e.md.options.html||(s=e.posMax,e.src.charCodeAt(a)!==60||a+2>=s)||(n=e.src.charCodeAt(a+1),n!==33&&n!==63&&n!==47&&!sp(n))||(o=e.src.slice(a).match(np),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length),ip(i.content)&&e.linkLevel++,op(i.content)&&e.linkLevel--),e.pos+=o[0].length,!0)}});var Kc=ne((v0,Yc)=>{"use strict";var Gc=Qo(),ap=Be().has,lp=Be().isValidEntityCode,Wc=Be().fromCodePoint,cp=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,up=/^&([a-z][a-z0-9]{1,31});/i;Yc.exports=function(e,t){var n,o,s,i,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(s=e.src.slice(a).match(cp),s)return t||(o=s[1][0].toLowerCase()==="x"?parseInt(s[1].slice(1),16):parseInt(s[1],10),i=e.push("text_special","",0),i.content=lp(o)?Wc(o):Wc(65533),i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(up),s&&ap(Gc,s[1]))return t||(i=e.push("text_special","",0),i.content=Gc[s[1]],i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0;return!1}});var Qc=ne((y0,Zc)=>{"use strict";function Xc(r,e){var t,n,o,s,i,a,l,c,u={},d=e.length;if(d){var h=0,f=-2,p=[];for(t=0;t<d;t++)if(o=e[t],p.push(0),(e[h].marker!==o.marker||f!==o.token-1)&&(h=t),f=o.token,o.length=o.length||0,!!o.close){for(u.hasOwnProperty(o.marker)||(u[o.marker]=[-1,-1,-1,-1,-1,-1]),i=u[o.marker][(o.open?3:0)+o.length%3],n=h-p[h]-1,a=n;n>i;n-=p[n]+1)if(s=e[n],s.marker===o.marker&&s.open&&s.end<0&&(l=!1,(s.close||o.open)&&(s.length+o.length)%3===0&&(s.length%3!==0||o.length%3!==0)&&(l=!0),!l)){c=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+c,p[n]=c,o.open=!1,s.end=t,s.close=!1,a=-1,f=-2;break}a!==-1&&(u[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Zc.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(Xc(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&Xc(e,n[t].delimiters)}});var eu=ne((b0,Jc)=>{"use strict";Jc.exports=function(e){var t,n,o=0,s=e.tokens,i=e.tokens.length;for(t=n=0;t<i;t++)s[t].nesting<0&&o--,s[t].level=o,s[t].nesting>0&&o++,s[t].type==="text"&&t+1<i&&s[t+1].type==="text"?s[t+1].content=s[t].content+s[t+1].content:(t!==n&&(s[n]=s[t]),n++);t!==n&&(s.length=n)}});var ou=ne((x0,iu)=>{"use strict";var vs=ki(),tu=Be().isWhiteSpace,ru=Be().isPunctChar,nu=Be().isMdAsciiPunct;function cn(r,e,t,n){this.src=r,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}cn.prototype.pushPending=function(){var r=new vs("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};cn.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new vs(r,e,t),o=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=[],o={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(o),n};cn.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,c,u,d,h=!0,f=!0,p=this.posMax,v=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===v;)t++;return s=t-r,o=t<p?this.src.charCodeAt(t):32,c=nu(n)||ru(String.fromCharCode(n)),d=nu(o)||ru(String.fromCharCode(o)),l=tu(n),u=tu(o),u?h=!1:d&&(l||c||(h=!1)),l?f=!1:c&&(u||d||(f=!1)),e?(i=h,a=f):(i=h&&(!f||c),a=f&&(!h||d)),{can_open:i,can_close:a,length:s}};cn.prototype.Token=vs;iu.exports=cn});var lu=ne((w0,au)=>{"use strict";var su=Si(),ys=[["text",Tc()],["linkify",Dc()],["newline",Fc()],["escape",Oc()],["backticks",Mc()],["strikethrough",hs().tokenize],["emphasis",ps().tokenize],["link",Nc()],["image",zc()],["autolink",Hc()],["html_inline",qc()],["entity",Kc()]],bs=[["balance_pairs",Qc()],["strikethrough",hs().postProcess],["emphasis",ps().postProcess],["fragments_join",eu()]];function un(){var r;for(this.ruler=new su,r=0;r<ys.length;r++)this.ruler.push(ys[r][0],ys[r][1]);for(this.ruler2=new su,r=0;r<bs.length;r++)this.ruler2.push(bs[r][0],bs[r][1])}un.prototype.skipToken=function(r){var e,t,n=r.pos,o=this.ruler.getRules(""),s=o.length,i=r.md.options.maxNesting,a=r.cache;if(typeof a[n]<"u"){r.pos=a[n];return}if(r.level<i)for(t=0;t<s&&(r.level++,e=o[t](r,!0),r.level--,!e);t++);else r.pos=r.posMax;e||r.pos++,a[n]=r.pos};un.prototype.tokenize=function(r){for(var e,t,n=this.ruler.getRules(""),o=n.length,s=r.posMax,i=r.md.options.maxNesting;r.pos<s;){if(r.level<i)for(t=0;t<o&&(e=n[t](r,!1),!e);t++);if(e){if(r.pos>=s)break;continue}r.pending+=r.src[r.pos++]}r.pending&&r.pushPending()};un.prototype.parse=function(r,e,t,n){var o,s,i,a=new this.State(r,e,t,n);for(this.tokenize(a),s=this.ruler2.getRules(""),i=s.length,o=0;o<i;o++)s[o](a)};un.prototype.State=ou();au.exports=un});var uu=ne((C0,cu)=>{"use strict";cu.exports=function(r){var e={};r=r||{},e.src_Any=es().source,e.src_Cc=ts().source,e.src_Z=rs().source,e.src_P=bi().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+")(?!"+(r["---"]?"-(?!--)|":"-|")+"_|:\\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+"|[.]|$)|"+(r["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+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 mu=ne((E0,pu)=>{"use strict";function xs(r){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){t&&Object.keys(t).forEach(function(n){r[n]=t[n]})}),r}function Ri(r){return Object.prototype.toString.call(r)}function dp(r){return Ri(r)==="[object String]"}function hp(r){return Ri(r)==="[object Object]"}function fp(r){return Ri(r)==="[object RegExp]"}function du(r){return Ri(r)==="[object Function]"}function pp(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var fu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function mp(r){return Object.keys(r||{}).reduce(function(e,t){return e||fu.hasOwnProperty(t)},!1)}var gp={"http:":{validate:function(r,e,t){var n=r.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(r,e,t){var n=r.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&&r[e-3]===":"||e>=3&&r[e-3]==="/"?0:n.match(t.re.no_http)[0].length:0}},"mailto:":{validate:function(r,e,t){var n=r.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}}},vp="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]",yp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function bp(r){r.__index__=-1,r.__text_cache__=""}function xp(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function hu(){return function(r,e){e.normalize(r)}}function Fi(r){var e=r.re=uu()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(vp),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 o=[];r.__compiled__={};function s(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(r.__schemas__).forEach(function(a){var l=r.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(r.__compiled__[a]=c,hp(l)){fp(l.validate)?c.validate=xp(l.validate):du(l.validate)?c.validate=l.validate:s(a,l),du(l.normalize)?c.normalize=l.normalize:l.normalize?s(a,l):c.normalize=hu();return}if(dp(l)){o.push(a);return}s(a,l)}}),o.forEach(function(a){r.__compiled__[r.__schemas__[a]]&&(r.__compiled__[a].validate=r.__compiled__[r.__schemas__[a]].validate,r.__compiled__[a].normalize=r.__compiled__[r.__schemas__[a]].normalize)}),r.__compiled__[""]={validate:null,normalize:hu()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(pp).join("|");r.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+i+")","i"),r.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+i+")","ig"),r.re.schema_at_start=RegExp("^"+r.re.schema_search.source,"i"),r.re.pretest=RegExp("("+r.re.schema_test.source+")|("+r.re.host_fuzzy_test.source+")|@","i"),bp(r)}function wp(r,e){var t=r.__index__,n=r.__last_index__,o=r.__text_cache__.slice(t,n);this.schema=r.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=n+e,this.raw=o,this.text=o,this.url=o}function ws(r,e){var t=new wp(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function At(r,e){if(!(this instanceof At))return new At(r,e);e||mp(r)&&(e=r,r={}),this.__opts__=xs({},fu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=xs({},gp,r),this.__compiled__={},this.__tlds__=yp,this.__tlds_replaced__=!1,this.re={},Fi(this)}At.prototype.add=function(e,t){return this.__schemas__[e]=t,Fi(this),this};At.prototype.set=function(e){return this.__opts__=xs(this.__opts__,e),this};At.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,o,s,i,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(s=this.testSchemaAt(e,t[2],l.lastIndex),s){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+s;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&&(i=n.index+n[1].length,(this.__index__<0||i<this.__index__)&&(this.__schema__="",this.__index__=i,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(o=e.match(this.re.email_fuzzy))!==null&&(i=o.index+o[1].length,a=o.index+o[0].length,(this.__index__<0||i<this.__index__||i===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=a))),this.__index__>=0};At.prototype.pretest=function(e){return this.re.pretest.test(e)};At.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};At.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(ws(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(ws(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};At.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,ws(this,0)):null};At.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(n,o,s){return n!==s[o-1]}).reverse(),Fi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Fi(this),this)};At.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};At.prototype.onCompile=function(){};pu.exports=At});var Eu={};bo(Eu,{decode:()=>As,default:()=>Dp,encode:()=>ks,toASCII:()=>Cu,toUnicode:()=>wu,ucs2decode:()=>Ss,ucs2encode:()=>bu});function sr(r){throw new RangeError(Ap[r])}function kp(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function yu(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(Sp,".");let o=r.split("."),s=kp(o,e).join(".");return n+s}function Ss(r){let e=[],t=0,n=r.length;for(;t<n;){let o=r.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){let s=r.charCodeAt(t++);(s&64512)==56320?e.push(((o&1023)<<10)+(s&1023)+65536):(e.push(o),t--)}else e.push(o)}return e}var vu,Cp,Ep,Sp,Ap,Cs,Ht,Es,bu,Tp,gu,xu,As,ks,wu,Cu,Ip,Dp,Su=Od(()=>{"use strict";vu="-",Cp=/^xn--/,Ep=/[^\0-\x7F]/,Sp=/[\x2E\u3002\uFF0E\uFF61]/g,Ap={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Cs=36-1,Ht=Math.floor,Es=String.fromCharCode;bu=r=>String.fromCodePoint(...r),Tp=function(r){return r>=48&&r<58?26+(r-48):r>=65&&r<91?r-65:r>=97&&r<123?r-97:36},gu=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},xu=function(r,e,t){let n=0;for(r=t?Ht(r/700):r>>1,r+=Ht(r/e);r>Cs*26>>1;n+=36)r=Ht(r/Cs);return Ht(n+(Cs+1)*r/(r+38))},As=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(vu);i<0&&(i=0);for(let a=0;a<i;++a)r.charCodeAt(a)>=128&&sr("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a<t;){let l=n;for(let u=1,d=36;;d+=36){a>=t&&sr("invalid-input");let h=Tp(r.charCodeAt(a++));h>=36&&sr("invalid-input"),h>Ht((2147483647-n)/u)&&sr("overflow"),n+=h*u;let f=d<=s?1:d>=s+26?26:d-s;if(h<f)break;let p=36-f;u>Ht(2147483647/p)&&sr("overflow"),u*=p}let c=e.length+1;s=xu(n-l,c,l==0),Ht(n/c)>2147483647-o&&sr("overflow"),o+=Ht(n/c),n%=c,e.splice(n++,0,o)}return String.fromCodePoint(...e)},ks=function(r){let e=[];r=Ss(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(Es(l));let i=e.length,a=i;for(i&&e.push(vu);a<t;){let l=2147483647;for(let u of r)u>=n&&u<l&&(l=u);let c=a+1;l-n>Ht((2147483647-o)/c)&&sr("overflow"),o+=(l-n)*c,n=l;for(let u of r)if(u<n&&++o>2147483647&&sr("overflow"),u===n){let d=o;for(let h=36;;h+=36){let f=h<=s?1:h>=s+26?26:h-s;if(d<f)break;let p=d-f,v=36-f;e.push(Es(gu(f+p%v,0))),d=Ht(p/v)}e.push(Es(gu(d,0))),s=xu(o,c,a===i),o=0,++a}++o,++n}return e.join("")},wu=function(r){return yu(r,function(e){return Cp.test(e)?As(e.slice(4).toLowerCase()):e})},Cu=function(r){return yu(r,function(e){return Ep.test(e)?"xn--"+ks(e):e})},Ip={version:"2.1.0",ucs2:{decode:Ss,encode:bu},decode:As,encode:ks,toASCII:Cu,toUnicode:wu},Dp=Ip});var ku=ne((S0,Au)=>{"use strict";Au.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 Iu=ne((A0,Tu)=>{"use strict";Tu.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 Lu=ne((k0,Du)=>{"use strict";Du.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 Pu=ne((T0,Ou)=>{"use strict";var dn=Be(),Lp=fl(),Fp=ml(),Rp=jl(),Op=Ac(),Pp=lu(),Mp=mu(),mr=Jo(),Fu=(Su(),Pd(Eu)),$p={default:ku(),zero:Iu(),commonmark:Lu()},_p=/^(vbscript|javascript|file|data):/,Bp=/^data:image\/(gif|png|jpeg|webp);/;function Np(r){var e=r.trim().toLowerCase();return _p.test(e)?!!Bp.test(e):!0}var Ru=["http:","https:","mailto:"];function Up(r){var e=mr.parse(r,!0);if(e.hostname&&(!e.protocol||Ru.indexOf(e.protocol)>=0))try{e.hostname=Fu.toASCII(e.hostname)}catch{}return mr.encode(mr.format(e))}function zp(r){var e=mr.parse(r,!0);if(e.hostname&&(!e.protocol||Ru.indexOf(e.protocol)>=0))try{e.hostname=Fu.toUnicode(e.hostname)}catch{}return mr.decode(mr.format(e),mr.decode.defaultChars+"%")}function Dt(r,e){if(!(this instanceof Dt))return new Dt(r,e);e||dn.isString(r)||(e=r||{},r="default"),this.inline=new Pp,this.block=new Op,this.core=new Rp,this.renderer=new Fp,this.linkify=new Mp,this.validateLink=Np,this.normalizeLink=Up,this.normalizeLinkText=zp,this.utils=dn,this.helpers=dn.assign({},Lp),this.options={},this.configure(r),e&&this.set(e)}Dt.prototype.set=function(r){return dn.assign(this.options,r),this};Dt.prototype.configure=function(r){var e=this,t;if(dn.isString(r)&&(t=r,r=$p[t],!r))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!r)throw new Error("Wrong `markdown-it` preset, can't be empty");return r.options&&e.set(r.options),r.components&&Object.keys(r.components).forEach(function(n){r.components[n].rules&&e[n].ruler.enableOnly(r.components[n].rules),r.components[n].rules2&&e[n].ruler2.enableOnly(r.components[n].rules2)}),this};Dt.prototype.enable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(o){t=t.concat(this[o].ruler.enable(r,!0))},this),t=t.concat(this.inline.ruler2.enable(r,!0));var n=r.filter(function(o){return t.indexOf(o)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this};Dt.prototype.disable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(o){t=t.concat(this[o].ruler.disable(r,!0))},this),t=t.concat(this.inline.ruler2.disable(r,!0));var n=r.filter(function(o){return t.indexOf(o)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this};Dt.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};Dt.prototype.parse=function(r,e){if(typeof r!="string")throw new Error("Input data should be a String");var t=new this.core.State(r,this,e);return this.core.process(t),t.tokens};Dt.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};Dt.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};Dt.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};Ou.exports=Dt});var $u=ne((I0,Mu)=>{"use strict";Mu.exports=Pu()});var zu=ne((D0,Uu)=>{var Ts=!0,Bu=!1,Nu=!1;Uu.exports=function(r,e){e&&(Ts=!e.enabled,Bu=!!e.label,Nu=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o<n.length;o++)Hp(n,o)&&(Vp(n[o],t.Token),_u(n[o-2],"class","task-list-item"+(Ts?"":" enabled")),_u(n[jp(n,o-2)],"class","contains-task-list"))})};function _u(r,e,t){var n=r.attrIndex(e),o=[e,t];n<0?r.attrPush(o):r.attrs[n]=o}function jp(r,e){for(var t=r[e].level-1,n=e-1;n>=0;n--)if(r[n].level===t)return n;return-1}function Hp(r,e){return Kp(r[e])&&Xp(r[e-1])&&Zp(r[e-2])&&Qp(r[e])}function Vp(r,e){if(r.children.unshift(qp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),Bu)if(Nu){r.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);r.children[0].content=r.children[0].content.slice(0,-1)+' id="'+t+'">',r.children.push(Yp(r.content,t,e))}else r.children.unshift(Gp(e)),r.children.push(Wp(e))}function qp(r,e){var t=new e("html_inline","",0),n=Ts?' disabled="" ':"";return r.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+n+'type="checkbox">':(r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+n+'type="checkbox">'),t}function Gp(r){var e=new r("html_inline","",0);return e.content="<label>",e}function Wp(r){var e=new r("html_inline","",0);return e.content="</label>",e}function Yp(r,e,t){var n=new t("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+e+'">'+r+"</label>",n.attrs=[{for:e}],n}function Kp(r){return r.type==="inline"}function Xp(r){return r.type==="paragraph_open"}function Zp(r){return r.type==="list_item_open"}function Qp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var nd=ne((mn,Bs)=>{(function(r,e){typeof mn=="object"&&typeof Bs=="object"?Bs.exports=e():typeof define=="function"&&define.amd?define([],e):typeof mn=="object"?mn.ClipboardJS=e():r.ClipboardJS=e()})(mn,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return S}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),c=s.n(l);function u(O){try{return document.execCommand(O)}catch{return}}var d=function(O){return O=c()(O),u("cut"),O};function h(P,A){var D,I,P=(D=P,I=document.documentElement.getAttribute("dir")==="rtl",(P=document.createElement("textarea")).style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[I?"right":"left"]="-9999px",I=window.pageYOffset||document.documentElement.scrollTop,P.style.top="".concat(I,"px"),P.setAttribute("readonly",""),P.value=D,P);return A.container.appendChild(P),A=c()(P),u("copy"),P.remove(),A}var f=function(O){var A=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof O=="string"?D=h(O,A):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O?.type)?D=h(O.value,A):(D=c()(O),u("copy")),D};function p(O){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}var v=function(){var I=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=I.action,O=D===void 0?"copy":D,A=I.container,D=I.target,I=I.text;if(O!=="copy"&&O!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0){if(!D||p(D)!=="object"||D.nodeType!==1)throw new Error('Invalid "target" value, use a valid Element');if(O==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(O==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}return I?f(I,{container:A}):D?O==="cut"?d(D):f(D,{container:A}):void 0};function y(O){return(y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}function b(O,A){for(var D=0;D<A.length;D++){var I=A[D];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(O,I.key,I)}}function x(O,A){return(x=Object.setPrototypeOf||function(D,I){return D.__proto__=I,D})(O,A)}function T(O){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var D,I=C(O);return D=A?(D=C(this).constructor,Reflect.construct(I,arguments,D)):I.apply(this,arguments),I=this,!(D=D)||y(D)!=="object"&&typeof D!="function"?function(P){if(P!==void 0)return P;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(I):D}}function C(O){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(O)}function M(O,A){if(O="data-clipboard-".concat(O),A.hasAttribute(O))return A.getAttribute(O)}var S=function(){(function(_,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function");_.prototype=Object.create(B&&B.prototype,{constructor:{value:_,writable:!0,configurable:!0}}),B&&x(_,B)})(P,i());var O,A,D,I=T(P);function P(_,B){var H;return function(Q){if(!(Q instanceof P))throw new TypeError("Cannot call a class as a function")}(this),(H=I.call(this)).resolveOptions(B),H.listenClick(_),H}return O=P,D=[{key:"copy",value:function(_){var B=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return f(_,B)}},{key:"cut",value:function(_){return d(_)}},{key:"isSupported",value:function(){var _=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],_=typeof _=="string"?[_]:_,B=!!document.queryCommandSupported;return _.forEach(function(H){B=B&&!!document.queryCommandSupported(H)}),B}}],(A=[{key:"resolveOptions",value:function(){var _=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof _.action=="function"?_.action:this.defaultAction,this.target=typeof _.target=="function"?_.target:this.defaultTarget,this.text=typeof _.text=="function"?_.text:this.defaultText,this.container=y(_.container)==="object"?_.container:document.body}},{key:"listenClick",value:function(_){var B=this;this.listener=a()(_,"click",function(H){return B.onClick(H)})}},{key:"onClick",value:function(Q){var B=Q.delegateTarget||Q.currentTarget,H=this.action(B)||"copy",Q=v({action:H,container:this.container,target:this.target(B),text:this.text(B)});this.emit(Q?"success":"error",{action:H,text:Q,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(_){return M("action",_)}},{key:"defaultTarget",value:function(_){if(_=M("target",_),_)return document.querySelector(_)}},{key:"defaultText",value:function(_){return M("text",_)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(O.prototype,A),D&&b(O,D),P}()},828:function(n){var o;typeof Element>"u"||Element.prototype.matches||((o=Element.prototype).matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector),n.exports=function(s,i){for(;s&&s.nodeType!==9;){if(typeof s.matches=="function"&&s.matches(i))return s;s=s.parentNode}}},438:function(n,o,s){var i=s(828);function a(l,c,u,d,h){var f=function(p,v,y,b){return function(x){x.delegateTarget=i(x.target,v),x.delegateTarget&&b.call(p,x)}}.apply(this,arguments);return l.addEventListener(u,f,h),{destroy:function(){l.removeEventListener(u,f,h)}}}n.exports=function(l,c,u,d,h){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof u=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(f){return a(f,c,u,d,h)}))}},879:function(n,o){o.node=function(s){return s!==void 0&&s instanceof HTMLElement&&s.nodeType===1},o.nodeList=function(s){var i=Object.prototype.toString.call(s);return s!==void 0&&(i==="[object NodeList]"||i==="[object HTMLCollection]")&&"length"in s&&(s.length===0||o.node(s[0]))},o.string=function(s){return typeof s=="string"||s instanceof String},o.fn=function(s){return Object.prototype.toString.call(s)==="[object Function]"}},370:function(n,o,s){var i=s(879),a=s(438);n.exports=function(l,c,u){if(!l&&!c&&!u)throw new Error("Missing required arguments");if(!i.string(c))throw new TypeError("Second argument must be a String");if(!i.fn(u))throw new TypeError("Third argument must be a Function");if(i.node(l))return v=c,y=u,(p=l).addEventListener(v,y),{destroy:function(){p.removeEventListener(v,y)}};if(i.nodeList(l))return d=l,h=c,f=u,Array.prototype.forEach.call(d,function(b){b.addEventListener(h,f)}),{destroy:function(){Array.prototype.forEach.call(d,function(b){b.removeEventListener(h,f)})}};if(i.string(l))return l=l,c=c,u=u,a(document.body,l,c,u);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var d,h,f,p,v,y}},817:function(n){n.exports=function(o){var s,i=o.nodeName==="SELECT"?(o.focus(),o.value):o.nodeName==="INPUT"||o.nodeName==="TEXTAREA"?((s=o.hasAttribute("readonly"))||o.setAttribute("readonly",""),o.select(),o.setSelectionRange(0,o.value.length),s||o.removeAttribute("readonly"),o.value):(o.hasAttribute("contenteditable")&&o.focus(),i=window.getSelection(),(s=document.createRange()).selectNodeContents(o),i.removeAllRanges(),i.addRange(s),i.toString());return i}},279:function(n){function o(){}o.prototype={on:function(s,i,a){var l=this.e||(this.e={});return(l[s]||(l[s]=[])).push({fn:i,ctx:a}),this},once:function(s,i,a){var l=this;function c(){l.off(s,c),i.apply(a,arguments)}return c._=i,this.on(s,c,a)},emit:function(s){for(var i=[].slice.call(arguments,1),a=((this.e||(this.e={}))[s]||[]).slice(),l=0,c=a.length;l<c;l++)a[l].fn.apply(a[l].ctx,i);return this},off:function(s,i){var a=this.e||(this.e={}),l=a[s],c=[];if(l&&i)for(var u=0,d=l.length;u<d;u++)l[u].fn!==i&&l[u].fn._!==i&&c.push(l[u]);return c.length?a[s]=c:delete a[s],this}},n.exports=o,n.exports.TinyEmitter=o}},t={},r.n=function(n){var o=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(o,{a:o}),o},r.d=function(n,o){for(var s in o)r.o(o,s)&&!r.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:o[s]})},r.o=function(n,o){return Object.prototype.hasOwnProperty.call(n,o)},r(686).default;function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var e,t})});var Br={},$d=[];function Nr(r,e){if($d.push({name:r,data:e}),typeof Br[r]>"u")return this;let t=Br[r];for(let n=0;n<t.length;n++){let o=t[n];o(e)}}function _d(r,e){typeof Br[r]>"u"&&(Br[r]=[]),Br[r].push(e)}function Bd(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function Nd(r){if(r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
+`);Nr("error",e)}}function Ud(r){r.status&&r.status>=400&&r.data&&r.data.message&&Nr("error",r.data.message)}var qs={emit:Nr,emitPublic:Bd,listen:_d,success:r=>Nr("success",r),error:r=>Nr("error",r),showValidationErrors:Nd,showResponseError:Ud};async function zd(r,e={}){return Gs(r,{method:"GET",params:e})}async function jd(r,e=null){return yn("POST",r,e)}async function Hd(r,e=null){return yn("PUT",r,e)}async function Vd(r,e=null){return yn("PATCH",r,e)}async function qd(r,e=null){return yn("DELETE",r,e)}async function yn(r,e,t=null){let n={method:r,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&&r!=="post"&&(t.append("_method",r),n.method="post"),Gs(e,n)}async function Gs(r,e={}){if(r.startsWith("http")||(r=window.baseUrl(r)),e.params){let i=new URL(r);for(let a of Object.keys(e.params)){let l=e.params[a];typeof l<"u"&&l!==null&&i.searchParams.set(a,l)}r=i.toString()}let t=document.querySelector("meta[name=token]").getAttribute("content");e=Object.assign({},e,{credentials:"same-origin"}),e.headers=Object.assign({},e.headers||{},{baseURL:window.baseUrl(""),"X-CSRF-TOKEN":t});let n=await fetch(r,e),o=await Gd(n),s={data:o,headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,url:n.url,original:n};if(!n.ok)throw new vn(n,o);return s}async function Gd(r){if(r.status===204)return null;let t=(r.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?await r.json():await r.text()}var vn=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}},Ws={get:zd,post:jd,put:Hd,patch:Vd,delete:qd,HttpError:vn};var wo=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),o=t.getAttribute("value");this.store.set(n,o)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let o=this.getTransText(e);return this.parsePlural(o,t,n)}parsePlural(e,t,n){let o=e.split("|"),s=/^{([0-9]+)}/,i=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let c=l.match(s);if(c!==null&&Number(c[1])===t){a=l.replace(s,"").trim();break}let u=l.match(i);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(i,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[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);return n===null||n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(e=e.replace(o,t[s]))}),e}},Ys=wo;var ko={};bo(ko,{first:()=>Xd,firstOnElement:()=>Qd,get:()=>Zd,init:()=>So,register:()=>Ao});function Co(r){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=r.split("-");return t[0]+t.slice(1).map(e).join("")}function Ks(r){return r.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var Ur={},Xs={},Eo=new WeakMap;function Wd(r,e){let t=Xs[r];if(t===void 0)return;let n;try{n=new t,n.$name=r,n.$el=e;let s=Yd(r,e);n.$refs=s.refs,n.$manyRefs=s.manyRefs,n.$opts=Kd(r,e),n.setup()}catch(s){console.error("Failed to create component",s,r,e)}typeof Ur[r]>"u"&&(Ur[r]=[]),Ur[r].push(n);let o=Eo.get(e)||{};o[r]=n,Eo.set(e,o)}function Yd(r,e){let t={},n={},o=`${r}@`,s=`[refs*="${o}"]`,i=[...e.querySelectorAll(s)];e.matches(s)&&i.push(e);for(let a of i){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(o)).map(c=>c.replace(o,"")).map(Co);for(let c of l)t[c]=a,typeof n[c]>"u"&&(n[c]=[]),n[c].push(a)}return{refs:t,manyRefs:n}}function Kd(r,e){let t={},n=`option:${r}:`;for(let{name:o,value:s}of e.attributes)if(o.startsWith(n)){let i=o.replace(n,"");t[Co(i)]=s||""}return t}function So(r=document){let e=r.querySelectorAll("[component],[components]");for(let t of e){let n=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let o of n)Wd(o,t)}}function Ao(r){let e=Object.keys(r);for(let t of e)Xs[Ks(t)]=r[t]}function Xd(r){return(Ur[r]||[null])[0]}function Zd(r){return Ur[r]||[]}function Qd(r,e){return(Eo.get(r)||{})[e]||null}var zs={};bo(zs,{AddRemoveRows:()=>wn,AjaxDeleteRow:()=>Cn,AjaxForm:()=>En,Attachments:()=>Sn,AttachmentsList:()=>An,AutoSubmit:()=>Tn,AutoSuggest:()=>kn,BackToTop:()=>In,BookSort:()=>Gn,ChapterContents:()=>Kn,CodeEditor:()=>Xn,CodeHighlighter:()=>Zn,CodeTextarea:()=>Qn,Collapsible:()=>Jn,ConfirmDialog:()=>ei,CustomCheckbox:()=>ti,DetailsHighlighter:()=>ri,Dropdown:()=>ni,DropdownSearch:()=>ii,Dropzone:()=>si,EditorToolbox:()=>ai,EntityPermissions:()=>li,EntitySearch:()=>ci,EntitySelector:()=>ui,EntitySelectorPopup:()=>di,EventEmitSelect:()=>hi,ExpandToggle:()=>fi,GlobalSearch:()=>pi,HeaderMobileToggle:()=>mi,ImageManager:()=>gi,ImagePicker:()=>vi,ListSortControl:()=>yi,MarkdownEditor:()=>Ui,NewUserPassword:()=>zi,Notification:()=>ji,OptionalInput:()=>Hi,PageComments:()=>Vi,PageDisplay:()=>qi,PageEditor:()=>Gi,PagePicker:()=>Yi,PermissionsTable:()=>Ki,Pointer:()=>Xi,Popup:()=>Zi,SettingAppColorScheme:()=>Qi,SettingColorPicker:()=>Ji,SettingHomepageControl:()=>eo,ShelfSort:()=>to,ShortcutInput:()=>no,Shortcuts:()=>ro,SortableList:()=>io,SubmitOnChange:()=>oo,Tabs:()=>so,TagManager:()=>ao,TemplateManager:()=>lo,ToggleSwitch:()=>co,TriLayout:()=>uo,UserSelect:()=>ho,WebhookEvents:()=>fo,WysiwygEditor:()=>go});function To(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function bn(r,e,t){for(let n of e)r.addEventListener(n,t)}function je(r,e){Array.isArray(r)||(r=[r]);for(let t of r)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function xn(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function We(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function Zs(r,e){let t=document.querySelectorAll(r);e=e.toLowerCase();for(let n of t)if(n.textContent.toLowerCase().includes(e))return n;return null}function zr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Qs(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function tr(r){let e=document.createElement("div");return e.innerHTML=r,window.$components.init(e),e.children[0]}function Bt(r,e,t){let n;return function(){let o=this,s=arguments,i=function(){n=null,t||r.apply(o,s)},a=t&&!n;clearTimeout(n),n=setTimeout(i,e),a&&r.apply(o,s)}}function jr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=getComputedStyle(document.body).getPropertyValue("--color-primary-light"),t=window.getComputedStyle(r).getPropertyValue("background-color");r.style.backgroundColor=e,setTimeout(()=>{r.classList.add("selectFade"),r.style.backgroundColor=t},10),setTimeout(()=>{r.classList.remove("selectFade"),r.style.backgroundColor=""},3e3)}function Js(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ea(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var V=class{constructor(){xr(this,"$name","");xr(this,"$el",null);xr(this,"$refs",{});xr(this,"$manyRefs",{});xr(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,o=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(o)}};var wn=class extends V{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)),We(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=ea(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}};var Cn=class extends V{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,je(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(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var En=class extends V{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}xn(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>je(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 Sn=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-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",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})})}reloadList(){this.stopEdit(),window.$components.firstOnElement(this.mainTabs,"tabs").show("attachment-panel-items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(t=>{this.list.innerHTML=t.data,window.$components.init(this.list)})}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.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),zr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}};var An=class extends V{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=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 Hr,Do,Vr,Lo,rr=class{constructor(e,t=null,n=null){xo(this,Hr);xo(this,Vr);this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",_r(this,Hr,Do).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",_r(this,Hr,Do).bind(this))}focusNext(){let e=_r(this,Vr,Lo).call(this),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=_r(this,Vr,Lo).call(this),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}};Hr=new WeakSet,Do=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))},Vr=new WeakSet,Lo=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 Fo={},kn=class extends V{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 rr(this.list,t=>{this.input.focus(),setTimeout(()=>this.hideSuggestions(),1)},t=>{t.preventDefault(),this.selectSuggestion(t.target.textContent)}).shareHandlingToEl(this.input),We(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(),o=(await this.loadSuggestions(t,e)).filter(s=>t===""||s.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(o)}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},o=`${this.url}:${JSON.stringify(n)}`;if(Fo[o])return Fo[o];let s=await window.$http.get(this.url,n);return Fo[o]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`<li><div tabindex="0" class="text-item">${Js(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 Tn=class extends V{setup(){this.form=this.$el,this.form.submit()}};var In=class extends V{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,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function i(){let a=1-(Date.now()-o)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(i.bind(this))):t.scrollTop=e}requestAnimationFrame(i.bind(this))}};function ta(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function Ut(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ta(Object(t),!0).forEach(function(n){Jd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ta(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Mn(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Mn=function(e){return typeof e}:Mn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mn(r)}function Jd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Pt(){return Pt=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Pt.apply(this,arguments)}function eh(r,e){if(r==null)return{};var t={},n=Object.keys(r),o,s;for(s=0;s<n.length;s++)o=n[s],!(e.indexOf(o)>=0)&&(t[o]=r[o]);return t}function th(r,e){if(r==null)return{};var t=eh(r,e),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(o=0;o<s.length;o++)n=s[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function rh(r){return nh(r)||ih(r)||oh(r)||sh()}function nh(r){if(Array.isArray(r))return jo(r)}function ih(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function oh(r,e){if(r){if(typeof r=="string")return jo(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return jo(r,e)}}function jo(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function sh(){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 ah="1.15.0";function Kt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Xt=Kt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),nn=Kt(/Edge/i),ra=Kt(/firefox/i),Qr=Kt(/safari/i)&&!Kt(/chrome/i)&&!Kt(/android/i),ha=Kt(/iP(ad|od|hone)/i),fa=Kt(/chrome/i)&&Kt(/android/i),pa={capture:!1,passive:!1};function De(r,e,t){r.addEventListener(e,t,!Xt&&pa)}function Te(r,e,t){r.removeEventListener(e,t,!Xt&&pa)}function Un(r,e){if(e){if(e[0]===">"&&(e=e.substring(1)),r)try{if(r.matches)return r.matches(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e)}catch{return!1}return!1}}function lh(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Ot(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&Un(r,e):Un(r,e))||n&&r===t)return r;if(r===t)break}while(r=lh(r))}return null}var na=/\s+/g;function it(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(na," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(na," ")}}function ue(r,e,t){var n=r&&r.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(r,""):r.currentStyle&&(t=r.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 hr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ue(r,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(r=r.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function ma(r,e,t){if(r){var n=r.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o<s;o++)t(n[o],o);return n}return[]}function Nt(){var r=document.scrollingElement;return r||document.documentElement}function Ke(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,c,u,d;if(r!==window&&r.parentNode&&r!==Nt()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,d=s.width):(i=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,d=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!Xt))do if(o&&o.getBoundingClientRect&&(ue(o,"transform")!=="none"||t&&ue(o,"position")!=="static")){var h=o.getBoundingClientRect();i-=h.top+parseInt(ue(o,"border-top-width")),a-=h.left+parseInt(ue(o,"border-left-width")),l=i+s.height,c=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var f=hr(o||r),p=f&&f.a,v=f&&f.d;f&&(i/=v,a/=p,d/=p,u/=v,l=i+u,c=a+d)}return{top:i,left:a,bottom:l,right:c,width:d,height:u}}}function ia(r,e,t){for(var n=or(r,!0),o=Ke(r)[e];n;){var s=Ke(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Nt())break;n=or(n,!1)}return!1}function kr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ye.ghost&&(n||i[s]!==ye.dragged)&&Ot(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function Wo(r,e){for(var t=r.lastElementChild;t&&(t===ye.ghost||ue(t,"display")==="none"||e&&!Un(t,e));)t=t.previousElementSibling;return t||null}function ot(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ye.clone&&(!e||Un(r,e))&&t++;return t}function oa(r){var e=0,t=0,n=Nt();if(r)do{var o=hr(r),s=o.a,i=o.d;e+=r.scrollLeft*s,t+=r.scrollTop*i}while(r!==n&&(r=r.parentNode));return[e,t]}function ch(r,e){for(var t in r)if(r.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r[t][n])return Number(t)}return-1}function or(r,e){if(!r||!r.getBoundingClientRect)return Nt();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ue(t);if(t.clientWidth<t.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Nt();if(n||e)return t;n=!0}}while(t=t.parentNode);return Nt()}function uh(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Ro(r,e){return Math.round(r.top)===Math.round(e.top)&&Math.round(r.left)===Math.round(e.left)&&Math.round(r.height)===Math.round(e.height)&&Math.round(r.width)===Math.round(e.width)}var Jr;function ga(r,e){return function(){if(!Jr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Jr=setTimeout(function(){Jr=void 0},e)}}}function dh(){clearTimeout(Jr),Jr=void 0}function va(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Yo(r){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(r).cloneNode(!0):t?t(r).clone(!0)[0]:r.cloneNode(!0)}function sa(r,e){ue(r,"position","absolute"),ue(r,"top",e.top),ue(r,"left",e.left),ue(r,"width",e.width),ue(r,"height",e.height)}function Oo(r){ue(r,"position",""),ue(r,"top",""),ue(r,"left",""),ue(r,"width",""),ue(r,"height","")}var pt="Sortable"+new Date().getTime();function hh(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ue(o,"display")==="none"||o===ye.ghost)){r.push({target:o,rect:Ke(o)});var s=Ut({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=hr(o,!0);i&&(s.top-=i.f,s.left-=i.e)}o.fromRect=s}})}},addAnimationState:function(n){r.push(n)},removeAnimationState:function(n){r.splice(ch(r,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,i=0;r.forEach(function(a){var l=0,c=a.target,u=c.fromRect,d=Ke(c),h=c.prevFromRect,f=c.prevToRect,p=a.rect,v=hr(c,!0);v&&(d.top-=v.f,d.left-=v.e),c.toRect=d,c.thisAnimationDuration&&Ro(h,d)&&!Ro(u,d)&&(p.top-d.top)/(p.left-d.left)===(u.top-d.top)/(u.left-d.left)&&(l=ph(p,h,f,o.options)),Ro(d,u)||(c.prevFromRect=u,c.prevToRect=d,l||(l=o.options.animation),o.animate(c,p,d,l)),l&&(s=!0,i=Math.max(i,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),s?e=setTimeout(function(){typeof n=="function"&&n()},i):typeof n=="function"&&n(),r=[]},animate:function(n,o,s,i){if(i){ue(n,"transition",""),ue(n,"transform","");var a=hr(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);n.animatingX=!!u,n.animatingY=!!d,ue(n,"transform","translate3d("+u+"px,"+d+"px,0)"),this.forRepaintDummy=fh(n),ue(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ue(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ue(n,"transition",""),ue(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function fh(r){return r.offsetWidth}function ph(r,e,t,n){return Math.sqrt(Math.pow(e.top-r.top,2)+Math.pow(e.left-r.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var wr=[],Po={initializeByDefault:!0},on={mount:function(e){for(var t in Po)Po.hasOwnProperty(t)&&!(t in e)&&(e[t]=Po[t]);wr.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),wr.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";wr.forEach(function(i){t[i.pluginName]&&(t[i.pluginName][s]&&t[i.pluginName][s](Ut({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Ut({sortable:t},n)))})},initializePlugins:function(e,t,n,o){wr.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,Pt(n,c.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var i=this.modifyOption(e,s,e.options[s]);typeof i<"u"&&(e.options[s]=i)}},getEventProperties:function(e,t){var n={};return wr.forEach(function(o){typeof o.eventProperties=="function"&&Pt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return wr.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function Yr(r){var e=r.sortable,t=r.rootEl,n=r.name,o=r.targetEl,s=r.cloneEl,i=r.toEl,a=r.fromEl,l=r.oldIndex,c=r.newIndex,u=r.oldDraggableIndex,d=r.newDraggableIndex,h=r.originalEvent,f=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[pt],!!e){var v,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Xt&&!nn?v=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(v=document.createEvent("Event"),v.initEvent(n,!0,!0)),v.to=i||t,v.from=a||t,v.item=o||t,v.clone=s,v.oldIndex=l,v.newIndex=c,v.oldDraggableIndex=u,v.newDraggableIndex=d,v.originalEvent=h,v.pullMode=f?f.lastPutMode:void 0;var x=Ut(Ut({},p),on.getEventProperties(n,e));for(var T in x)v[T]=x[T];t&&t.dispatchEvent(v),y[b]&&y[b].call(e,v)}}var mh=["evt"],bt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=th(n,mh);on.pluginEvent.bind(ye)(e,t,Ut({dragEl:te,parentEl:tt,ghostEl:Ee,rootEl:Ye,nextEl:dr,lastDownEl:$n,cloneEl:Qe,cloneHidden:ir,dragStarted:Kr,putSortable:ct,activeSortable:ye.active,originalEvent:o,oldIndex:Ar,oldDraggableIndex:en,newIndex:St,newDraggableIndex:nr,hideGhostForTarget:wa,unhideGhostForTarget:Ca,cloneNowHidden:function(){ir=!0},cloneNowShown:function(){ir=!1},dispatchSortableEvent:function(a){gt({sortable:t,name:a,originalEvent:o})}},s))};function gt(r){Yr(Ut({putSortable:ct,cloneEl:Qe,targetEl:te,rootEl:Ye,oldIndex:Ar,oldDraggableIndex:en,newIndex:St,newDraggableIndex:nr},r))}var te,tt,Ee,Ye,dr,$n,Qe,ir,Ar,St,en,nr,Dn,ct,Sr=!1,zn=!1,jn=[],cr,Ft,Mo,$o,aa,la,Kr,Cr,tn,rn=!1,Ln=!1,_n,ft,_o=[],Ho=!1,Hn=[],qn=typeof document<"u",Fn=ha,ca=nn||Xt?"cssFloat":"float",gh=qn&&!fa&&!ha&&"draggable"in document.createElement("div"),ya=function(){if(qn){if(Xt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),ba=function(e,t){var n=ue(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=kr(e,0,t),i=kr(e,1,t),a=s&&ue(s),l=i&&ue(i),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ke(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+Ke(i).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(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&n[ca]==="none"||i&&n[ca]==="none"&&c+u>o)?"vertical":"horizontal"},vh=function(e,t,n){var o=n?e.left:e.top,s=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,c=n?t.width:t.height;return o===a||s===l||o+i/2===a+c/2},yh=function(e,t){var n;return jn.some(function(o){var s=o[pt].options.emptyInsertThreshold;if(!(!s||Wo(o))){var i=Ke(o),a=e>=i.left-s&&e<=i.right+s,l=t>=i.top-s&&t<=i.bottom+s;if(a&&l)return n=o}}),n},xa=function(e){function t(s,i){return function(a,l,c,u){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||d))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,c,u),i)(a,l,c,u);var h=(i?a:l).options.group.name;return s===!0||typeof s=="string"&&s===h||s.join&&s.indexOf(h)>-1}}var n={},o=e.group;(!o||Mn(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=t(o.pull,!0),n.checkPut=t(o.put),n.revertClone=o.revertClone,e.group=n},wa=function(){!ya&&Ee&&ue(Ee,"display","none")},Ca=function(){!ya&&Ee&&ue(Ee,"display","")};qn&&!fa&&document.addEventListener("click",function(r){if(zn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),zn=!1,!1},!0);var ur=function(e){if(te){e=e.touches?e.touches[0]:e;var t=yh(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[pt]._onDragOver(n)}}},bh=function(e){te&&te.parentNode[pt]._isOutsideThisEl(e.target)};function ye(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=Pt({},e),r[pt]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(r.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ba(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(i,a){i.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:ye.supportPointer!==!1&&"PointerEvent"in window&&!Qr,emptyInsertThreshold:5};on.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);xa(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:gh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?De(r,"pointerdown",this._onTapStart):(De(r,"mousedown",this._onTapStart),De(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(De(r,"dragover",this),De(r,"dragenter",this)),jn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Pt(this,hh())}ye.prototype={constructor:ye,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Cr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,te):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,i=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=o.filter;if(Th(n),!te&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Qr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Ot(l,o.draggable,n,!1),!(l&&l.animated)&&$n!==l)){if(Ar=ot(l),en=ot(l,o.draggable),typeof u=="function"){if(u.call(this,e,l,this)){gt({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),bt("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(d){if(d=Ot(c,d.trim(),n,!1),d)return gt({sortable:t,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),bt("filter",t,{evt:e}),!0}),u)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Ot(c,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,i=o.options,a=s.ownerDocument,l;if(n&&!te&&n.parentNode===s){var c=Ke(n);if(Ye=s,te=n,tt=te.parentNode,dr=te.nextSibling,$n=n,Dn=i.group,ye.dragged=te,cr={target:te,clientX:(t||e).clientX,clientY:(t||e).clientY},aa=cr.clientX-c.left,la=cr.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,te.style["will-change"]="all",l=function(){if(bt("delayEnded",o,{evt:e}),ye.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!ra&&o.nativeDraggable&&(te.draggable=!0),o._triggerDragStart(e,t),gt({sortable:o,name:"choose",originalEvent:e}),it(te,i.chosenClass,!0)},i.ignore.split(",").forEach(function(u){ma(te,u.trim(),Bo)}),De(a,"dragover",ur),De(a,"mousemove",ur),De(a,"touchmove",ur),De(a,"mouseup",o._onDrop),De(a,"touchend",o._onDrop),De(a,"touchcancel",o._onDrop),ra&&this.nativeDraggable&&(this.options.touchStartThreshold=4,te.draggable=!0),bt("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(nn||Xt))){if(ye.eventCanceled){this._onDrop();return}De(a,"mouseup",o._disableDelayedDrag),De(a,"touchend",o._disableDelayedDrag),De(a,"touchcancel",o._disableDelayedDrag),De(a,"mousemove",o._delayedDragTouchMoveHandler),De(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&De(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,i.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(){te&&Bo(te),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Te(e,"mouseup",this._disableDelayedDrag),Te(e,"touchend",this._disableDelayedDrag),Te(e,"touchcancel",this._disableDelayedDrag),Te(e,"mousemove",this._delayedDragTouchMoveHandler),Te(e,"touchmove",this._delayedDragTouchMoveHandler),Te(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?De(document,"pointermove",this._onTouchMove):t?De(document,"touchmove",this._onTouchMove):De(document,"mousemove",this._onTouchMove):(De(te,"dragend",this),De(Ye,"dragstart",this._onDragStart));try{document.selection?Bn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(Sr=!1,Ye&&te){bt("dragStarted",this,{evt:t}),this.nativeDraggable&&De(document,"dragover",bh);var n=this.options;!e&&it(te,n.dragClass,!1),it(te,n.ghostClass,!0),ye.active=this,e&&this._appendGhost(),gt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Ft){this._lastX=Ft.clientX,this._lastY=Ft.clientY,wa();for(var e=document.elementFromPoint(Ft.clientX,Ft.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Ft.clientX,Ft.clientY),e!==t);)t=e;if(te.parentNode[pt]._isOutsideThisEl(e),t)do{if(t[pt]){var n=void 0;if(n=t[pt]._onDragOver({clientX:Ft.clientX,clientY:Ft.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ca()}},_onTouchMove:function(e){if(cr){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=Ee&&hr(Ee,!0),a=Ee&&i&&i.a,l=Ee&&i&&i.d,c=Fn&&ft&&oa(ft),u=(s.clientX-cr.clientX+o.x)/(a||1)+(c?c[0]-_o[0]:0)/(a||1),d=(s.clientY-cr.clientY+o.y)/(l||1)+(c?c[1]-_o[1]:0)/(l||1);if(!ye.active&&!Sr){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(Ee){i?(i.e+=u-(Mo||0),i.f+=d-($o||0)):i={a:1,b:0,c:0,d:1,e:u,f:d};var h="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ue(Ee,"webkitTransform",h),ue(Ee,"mozTransform",h),ue(Ee,"msTransform",h),ue(Ee,"transform",h),Mo=u,$o=d,Ft=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!Ee){var e=this.options.fallbackOnBody?document.body:Ye,t=Ke(te,!0,Fn,!0,e),n=this.options;if(Fn){for(ft=e;ue(ft,"position")==="static"&&ue(ft,"transform")==="none"&&ft!==document;)ft=ft.parentNode;ft!==document.body&&ft!==document.documentElement?(ft===document&&(ft=Nt()),t.top+=ft.scrollTop,t.left+=ft.scrollLeft):ft=Nt(),_o=oa(ft)}Ee=te.cloneNode(!0),it(Ee,n.ghostClass,!1),it(Ee,n.fallbackClass,!0),it(Ee,n.dragClass,!0),ue(Ee,"transition",""),ue(Ee,"transform",""),ue(Ee,"box-sizing","border-box"),ue(Ee,"margin",0),ue(Ee,"top",t.top),ue(Ee,"left",t.left),ue(Ee,"width",t.width),ue(Ee,"height",t.height),ue(Ee,"opacity","0.8"),ue(Ee,"position",Fn?"absolute":"fixed"),ue(Ee,"zIndex","100000"),ue(Ee,"pointerEvents","none"),ye.ghost=Ee,e.appendChild(Ee),ue(Ee,"transform-origin",aa/parseInt(Ee.style.width)*100+"% "+la/parseInt(Ee.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(bt("dragStart",this,{evt:e}),ye.eventCanceled){this._onDrop();return}bt("setupClone",this),ye.eventCanceled||(Qe=Yo(te),Qe.removeAttribute("id"),Qe.draggable=!1,Qe.style["will-change"]="",this._hideClone(),it(Qe,this.options.chosenClass,!1),ye.clone=Qe),n.cloneId=Bn(function(){bt("clone",n),!ye.eventCanceled&&(n.options.removeCloneOnHide||Ye.insertBefore(Qe,te),n._hideClone(),gt({sortable:n,name:"clone"}))}),!t&&it(te,s.dragClass,!0),t?(zn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Te(document,"mouseup",n._onDrop),Te(document,"touchend",n._onDrop),Te(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,te)),De(document,"drop",n),ue(te,"transform","translateZ(0)")),Sr=!0,n._dragStartId=Bn(n._dragStarted.bind(n,t,e)),De(document,"selectstart",n),Kr=!0,Qr&&ue(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,c=ye.active,u=Dn===l,d=a.sort,h=ct||c,f,p=this,v=!1;if(Ho)return;function y(ie,xe){bt(ie,p,Ut({evt:e,isOwner:u,axis:f?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:d,fromSortable:h,target:n,completed:x,onMove:function(Ce,Pe){return Rn(Ye,t,te,o,Ce,Ke(Ce),e,Pe)},changed:T},xe))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ie){return y("dragOverCompleted",{insertion:ie}),ie&&(u?c._hideClone():c._showClone(p),p!==h&&(it(te,ct?ct.options.ghostClass:c.options.ghostClass,!1),it(te,a.ghostClass,!0)),ct!==p&&p!==ye.active?ct=p:p===ye.active&&ct&&(ct=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===te&&!te.animated||n===t&&!n.animated)&&(Cr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(te.parentNode[pt]._isOutsideThisEl(e.target),!ie&&ur(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),v=!0}function T(){St=ot(te),nr=ot(te,a.draggable),gt({sortable:p,name:"change",toEl:t,newIndex:St,newDraggableIndex:nr,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Ot(n,a.draggable,t,!0),y("dragOver"),ye.eventCanceled)return v;if(te.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(zn=!1,c&&!a.disabled&&(u?d||(i=tt!==Ye):ct===this||(this.lastPutMode=Dn.checkPull(this,c,te,e))&&l.checkPut(this,c,te,e))){if(f=this._getDirection(e,n)==="vertical",o=Ke(te),y("dragOverValid"),ye.eventCanceled)return v;if(i)return tt=Ye,b(),this._hideClone(),y("revert"),ye.eventCanceled||(dr?Ye.insertBefore(te,dr):Ye.appendChild(te)),x(!0);var C=Wo(t,a.draggable);if(!C||Eh(e,f,this)&&!C.animated){if(C===te)return x(!1);if(C&&t===e.target&&(n=C),n&&(s=Ke(n)),Rn(Ye,t,te,o,n,s,e,!!n)!==!1)return b(),C&&C.nextSibling?t.insertBefore(te,C.nextSibling):t.appendChild(te),tt=t,T(),x(!0)}else if(C&&Ch(e,f,this)){var M=kr(t,0,a,!0);if(M===te)return x(!1);if(n=M,s=Ke(n),Rn(Ye,t,te,o,n,s,e,!1)!==!1)return b(),t.insertBefore(te,M),tt=t,T(),x(!0)}else if(n.parentNode===t){s=Ke(n);var S=0,O,A=te.parentNode!==t,D=!vh(te.animated&&te.toRect||o,n.animated&&n.toRect||s,f),I=f?"top":"left",P=ia(n,"top","top")||ia(te,"top","top"),_=P?P.scrollTop:void 0;Cr!==n&&(O=s[I],rn=!1,Ln=!D&&a.invertSwap||A),S=Sh(e,n,s,f,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,Ln,Cr===n);var B;if(S!==0){var H=ot(te);do H-=S,B=tt.children[H];while(B&&(ue(B,"display")==="none"||B===Ee))}if(S===0||B===n)return x(!1);Cr=n,tn=S;var Q=n.nextElementSibling,Y=!1;Y=S===1;var re=Rn(Ye,t,te,o,n,s,e,Y);if(re!==!1)return(re===1||re===-1)&&(Y=re===1),Ho=!0,setTimeout(wh,30),b(),Y&&!Q?t.appendChild(te):n.parentNode.insertBefore(te,Y?Q:n),P&&va(P,0,_-P.scrollTop),tt=te.parentNode,O!==void 0&&!Ln&&(_n=Math.abs(O-Ke(n)[I])),T(),x(!0)}if(t.contains(te))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Te(document,"mousemove",this._onTouchMove),Te(document,"touchmove",this._onTouchMove),Te(document,"pointermove",this._onTouchMove),Te(document,"dragover",ur),Te(document,"mousemove",ur),Te(document,"touchmove",ur)},_offUpEvents:function(){var e=this.el.ownerDocument;Te(e,"mouseup",this._onDrop),Te(e,"touchend",this._onDrop),Te(e,"pointerup",this._onDrop),Te(e,"touchcancel",this._onDrop),Te(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(St=ot(te),nr=ot(te,n.draggable),bt("drop",this,{evt:e}),tt=te&&te.parentNode,St=ot(te),nr=ot(te,n.draggable),ye.eventCanceled){this._nulling();return}Sr=!1,Ln=!1,rn=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Vo(this.cloneId),Vo(this._dragStartId),this.nativeDraggable&&(Te(document,"drop",this),Te(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Qr&&ue(document.body,"user-select",""),ue(te,"transform",""),e&&(Kr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),Ee&&Ee.parentNode&&Ee.parentNode.removeChild(Ee),(Ye===tt||ct&&ct.lastPutMode!=="clone")&&Qe&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),te&&(this.nativeDraggable&&Te(te,"dragend",this),Bo(te),te.style["will-change"]="",Kr&&!Sr&&it(te,ct?ct.options.ghostClass:this.options.ghostClass,!1),it(te,this.options.chosenClass,!1),gt({sortable:this,name:"unchoose",toEl:tt,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ye!==tt?(St>=0&&(gt({rootEl:tt,name:"add",toEl:tt,fromEl:Ye,originalEvent:e}),gt({sortable:this,name:"remove",toEl:tt,originalEvent:e}),gt({rootEl:tt,name:"sort",toEl:tt,fromEl:Ye,originalEvent:e}),gt({sortable:this,name:"sort",toEl:tt,originalEvent:e})),ct&&ct.save()):St!==Ar&&St>=0&&(gt({sortable:this,name:"update",toEl:tt,originalEvent:e}),gt({sortable:this,name:"sort",toEl:tt,originalEvent:e})),ye.active&&((St==null||St===-1)&&(St=Ar,nr=en),gt({sortable:this,name:"end",toEl:tt,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){bt("nulling",this),Ye=te=tt=Ee=dr=Qe=$n=ir=cr=Ft=Kr=St=nr=Ar=en=Cr=tn=ct=Dn=ye.dragged=ye.ghost=ye.clone=ye.active=null,Hn.forEach(function(e){e.checked=!0}),Hn.length=Mo=$o=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":te&&(this._onDragOver(e),xh(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,o=0,s=n.length,i=this.options;o<s;o++)t=n[o],Ot(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||kh(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Ot(a,this.options.draggable,o,!1)&&(n[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return Ot(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var o=on.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&xa(n)},destroy:function(){bt("destroy",this);var e=this.el;e[pt]=null,Te(e,"mousedown",this._onTapStart),Te(e,"touchstart",this._onTapStart),Te(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Te(e,"dragover",this),Te(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),jn.splice(jn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!ir){if(bt("hideClone",this),ye.eventCanceled)return;ue(Qe,"display","none"),this.options.removeCloneOnHide&&Qe.parentNode&&Qe.parentNode.removeChild(Qe),ir=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(ir){if(bt("showClone",this),ye.eventCanceled)return;te.parentNode==Ye&&!this.options.group.revertClone?Ye.insertBefore(Qe,te):dr?Ye.insertBefore(Qe,dr):Ye.appendChild(Qe),this.options.group.revertClone&&this.animate(te,Qe),ue(Qe,"display",""),ir=!1}}};function xh(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function Rn(r,e,t,n,o,s,i,a){var l,c=r[pt],u=c.options.onMove,d;return window.CustomEvent&&!Xt&&!nn?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=r,l.dragged=t,l.draggedRect=n,l.related=o||e,l.relatedRect=s||Ke(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),u&&(d=u.call(c,l,i)),d}function Bo(r){r.draggable=!1}function wh(){Ho=!1}function Ch(r,e,t){var n=Ke(kr(t.el,0,t.options,!0)),o=10;return e?r.clientX<n.left-o||r.clientY<n.top&&r.clientX<n.right:r.clientY<n.top-o||r.clientY<n.bottom&&r.clientX<n.left}function Eh(r,e,t){var n=Ke(Wo(t.el,t.options.draggable)),o=10;return e?r.clientX>n.right+o||r.clientX<=n.right&&r.clientY>n.bottom&&r.clientX>=n.left:r.clientX>n.right&&r.clientY>n.top||r.clientX<=n.right&&r.clientY>n.bottom+o}function Sh(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,c=n?t.height:t.width,u=n?t.top:t.left,d=n?t.bottom:t.right,h=!1;if(!i){if(a&&_n<c*o){if(!rn&&(tn===1?l>u+c*s/2:l<d-c*s/2)&&(rn=!0),rn)h=!0;else if(tn===1?l<u+_n:l>d-_n)return-tn}else if(l>u+c*(1-o)/2&&l<d-c*(1-o)/2)return Ah(e)}return h=h||i,h&&(l<u+c*s/2||l>d-c*s/2)?l>u+c/2?1:-1:0}function Ah(r){return ot(te)<ot(r)?1:-1}function kh(r){for(var e=r.tagName+r.className+r.src+r.href+r.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function Th(r){Hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&Hn.push(n)}}function Bn(r){return setTimeout(r,0)}function Vo(r){return clearTimeout(r)}qn&&De(document,"touchmove",function(r){(ye.active||Sr)&&r.cancelable&&r.preventDefault()});ye.utils={on:De,off:Te,css:ue,find:ma,is:function(e,t){return!!Ot(e,t,e,!1)},extend:uh,throttle:ga,closest:Ot,toggleClass:it,clone:Yo,index:ot,nextTick:Bn,cancelNextTick:Vo,detectDirection:ba,getChild:kr};ye.get=function(r){return r[pt]};ye.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;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&&(ye.utils=Ut(Ut({},ye.utils),n.utils)),on.mount(n)})};ye.create=function(r,e){return new ye(r,e)};ye.version=ah;var nt=[],Xr,qo,Go=!1,No,Uo,Vn,Zr;function Ih(){function r(){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 r.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?De(document,"dragover",this._handleAutoScroll):this.options.supportPointer?De(document,"pointermove",this._handleFallbackAutoScroll):n.touches?De(document,"touchmove",this._handleFallbackAutoScroll):De(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Te(document,"dragover",this._handleAutoScroll):(Te(document,"pointermove",this._handleFallbackAutoScroll),Te(document,"touchmove",this._handleFallbackAutoScroll),Te(document,"mousemove",this._handleFallbackAutoScroll)),ua(),Nn(),dh()},nulling:function(){Vn=qo=Xr=Go=Zr=No=Uo=null,nt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var o=this,s=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(s,i);if(Vn=t,n||this.options.forceAutoScrollFallback||nn||Xt||Qr){zo(t,this.options,a,n);var l=or(a,!0);Go&&(!Zr||s!==No||i!==Uo)&&(Zr&&ua(),Zr=setInterval(function(){var c=or(document.elementFromPoint(s,i),!0);c!==l&&(l=c,Nn()),zo(t,o.options,c,n)},10),No=s,Uo=i)}else{if(!this.options.bubbleScroll||or(a,!0)===Nt()){Nn();return}zo(t,this.options,or(a,!1),!1)}}},Pt(r,{pluginName:"scroll",initializeByDefault:!0})}function Nn(){nt.forEach(function(r){clearInterval(r.pid)}),nt=[]}function ua(){clearInterval(Zr)}var zo=ga(function(r,e,t,n){if(e.scroll){var o=(r.touches?r.touches[0]:r).clientX,s=(r.touches?r.touches[0]:r).clientY,i=e.scrollSensitivity,a=e.scrollSpeed,l=Nt(),c=!1,u;qo!==t&&(qo=t,Nn(),Xr=e.scroll,u=e.scrollFn,Xr===!0&&(Xr=or(t,!0)));var d=0,h=Xr;do{var f=h,p=Ke(f),v=p.top,y=p.bottom,b=p.left,x=p.right,T=p.width,C=p.height,M=void 0,S=void 0,O=f.scrollWidth,A=f.scrollHeight,D=ue(f),I=f.scrollLeft,P=f.scrollTop;f===l?(M=T<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=T<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var _=M&&(Math.abs(x-o)<=i&&I+T<O)-(Math.abs(b-o)<=i&&!!I),B=S&&(Math.abs(y-s)<=i&&P+C<A)-(Math.abs(v-s)<=i&&!!P);if(!nt[d])for(var H=0;H<=d;H++)nt[H]||(nt[H]={});(nt[d].vx!=_||nt[d].vy!=B||nt[d].el!==f)&&(nt[d].el=f,nt[d].vx=_,nt[d].vy=B,clearInterval(nt[d].pid),(_!=0||B!=0)&&(c=!0,nt[d].pid=setInterval(function(){n&&this.layer===0&&ye.active._onTouchMove(Vn);var Q=nt[this.layer].vy?nt[this.layer].vy*a:0,Y=nt[this.layer].vx?nt[this.layer].vx*a:0;typeof u=="function"&&u.call(ye.dragged.parentNode[pt],Y,Q,r,Vn,nt[this.layer].el)!=="continue"||va(nt[this.layer].el,Y,Q)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&h!==l&&(h=or(h,!1)));Go=c}},30),Ea=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,i=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=n||s;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,d=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(d)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Ko(){}Ko.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 o=kr(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(t,o):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:Ea};Pt(Ko,{pluginName:"revertOnSpill"});function Xo(){}Xo.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,o=n||this.sortable;o.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),o.animateAll()},drop:Ea};Pt(Xo,{pluginName:"removeOnSpill"});var we=[],Et=[],qr,Rt,Gr=!1,xt=!1,Er=!1,Ve,Wr,On;function Sa(){function r(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?De(document,"pointerup",this._deselectMultiDrag):(De(document,"mouseup",this._deselectMultiDrag),De(document,"touchend",this._deselectMultiDrag))),De(document,"keydown",this._checkKeyDown),De(document,"keyup",this._checkKeyUp),this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:!1,setData:function(o,s){var i="";we.length&&Rt===e?we.forEach(function(a,l){i+=(l?", ":"")+a.textContent}):i=s.textContent,o.setData("Text",i)}}}return r.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var n=t.dragEl;Ve=n},delayEnded:function(){this.isMultiDrag=~we.indexOf(Ve)},setupClone:function(t){var n=t.sortable,o=t.cancel;if(this.isMultiDrag){for(var s=0;s<we.length;s++)Et.push(Yo(we[s])),Et[s].sortableIndex=we[s].sortableIndex,Et[s].draggable=!1,Et[s].style["will-change"]="",it(Et[s],this.options.selectedClass,!1),we[s]===Ve&&it(Et[s],this.options.chosenClass,!1);n._hideClone(),o()}},clone:function(t){var n=t.sortable,o=t.rootEl,s=t.dispatchSortableEvent,i=t.cancel;this.isMultiDrag&&(this.options.removeCloneOnHide||we.length&&Rt===n&&(da(!0,o),s("clone"),i()))},showClone:function(t){var n=t.cloneNowShown,o=t.rootEl,s=t.cancel;this.isMultiDrag&&(da(!1,o),Et.forEach(function(i){ue(i,"display","")}),n(),On=!1,s())},hideClone:function(t){var n=this,o=t.sortable,s=t.cloneNowHidden,i=t.cancel;this.isMultiDrag&&(Et.forEach(function(a){ue(a,"display","none"),n.options.removeCloneOnHide&&a.parentNode&&a.parentNode.removeChild(a)}),s(),On=!0,i())},dragStartGlobal:function(t){var n=t.sortable;!this.isMultiDrag&&Rt&&Rt.multiDrag._deselectMultiDrag(),we.forEach(function(o){o.sortableIndex=ot(o)}),we=we.sort(function(o,s){return o.sortableIndex-s.sortableIndex}),Er=!0},dragStarted:function(t){var n=this,o=t.sortable;if(this.isMultiDrag){if(this.options.sort&&(o.captureAnimationState(),this.options.animation)){we.forEach(function(i){i!==Ve&&ue(i,"position","absolute")});var s=Ke(Ve,!1,!0,!0);we.forEach(function(i){i!==Ve&&sa(i,s)}),xt=!0,Gr=!0}o.animateAll(function(){xt=!1,Gr=!1,n.options.animation&&we.forEach(function(i){Oo(i)}),n.options.sort&&Pn()})}},dragOver:function(t){var n=t.target,o=t.completed,s=t.cancel;xt&&~we.indexOf(n)&&(o(!1),s())},revert:function(t){var n=t.fromSortable,o=t.rootEl,s=t.sortable,i=t.dragRect;we.length>1&&(we.forEach(function(a){s.addAnimationState({target:a,rect:xt?Ke(a):i}),Oo(a),a.fromRect=i,n.removeAnimationState(a)}),xt=!1,Dh(!this.options.removeCloneOnHide,o))},dragOverCompleted:function(t){var n=t.sortable,o=t.isOwner,s=t.insertion,i=t.activeSortable,a=t.parentEl,l=t.putSortable,c=this.options;if(s){if(o&&i._hideClone(),Gr=!1,c.animation&&we.length>1&&(xt||!o&&!i.options.sort&&!l)){var u=Ke(Ve,!1,!0,!0);we.forEach(function(h){h!==Ve&&(sa(h,u),a.appendChild(h))}),xt=!0}if(!o)if(xt||Pn(),we.length>1){var d=On;i._showClone(n),i.options.animation&&!On&&d&&Et.forEach(function(h){i.addAnimationState({target:h,rect:Wr}),h.fromRect=Wr,h.thisAnimationDuration=null})}else i._showClone(n)}},dragOverAnimationCapture:function(t){var n=t.dragRect,o=t.isOwner,s=t.activeSortable;if(we.forEach(function(a){a.thisAnimationDuration=null}),s.options.animation&&!o&&s.multiDrag.isMultiDrag){Wr=Pt({},n);var i=hr(Ve,!0);Wr.top-=i.f,Wr.left-=i.e}},dragOverAnimationComplete:function(){xt&&(xt=!1,Pn())},drop:function(t){var n=t.originalEvent,o=t.rootEl,s=t.parentEl,i=t.sortable,a=t.dispatchSortableEvent,l=t.oldIndex,c=t.putSortable,u=c||this.sortable;if(n){var d=this.options,h=s.children;if(!Er)if(d.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),it(Ve,d.selectedClass,!~we.indexOf(Ve)),~we.indexOf(Ve))we.splice(we.indexOf(Ve),1),qr=null,Yr({sortable:i,rootEl:o,name:"deselect",targetEl:Ve,originalEvent:n});else{if(we.push(Ve),Yr({sortable:i,rootEl:o,name:"select",targetEl:Ve,originalEvent:n}),n.shiftKey&&qr&&i.el.contains(qr)){var f=ot(qr),p=ot(Ve);if(~f&&~p&&f!==p){var v,y;for(p>f?(y=f,v=p):(y=p,v=f+1);y<v;y++)~we.indexOf(h[y])||(it(h[y],d.selectedClass,!0),we.push(h[y]),Yr({sortable:i,rootEl:o,name:"select",targetEl:h[y],originalEvent:n}))}}else qr=Ve;Rt=u}if(Er&&this.isMultiDrag){if(xt=!1,(s[pt].options.sort||s!==o)&&we.length>1){var b=Ke(Ve),x=ot(Ve,":not(."+this.options.selectedClass+")");if(!Gr&&d.animation&&(Ve.thisAnimationDuration=null),u.captureAnimationState(),!Gr&&(d.animation&&(Ve.fromRect=b,we.forEach(function(C){if(C.thisAnimationDuration=null,C!==Ve){var M=xt?Ke(C):b;C.fromRect=M,u.addAnimationState({target:C,rect:M})}})),Pn(),we.forEach(function(C){h[x]?s.insertBefore(C,h[x]):s.appendChild(C),x++}),l===ot(Ve))){var T=!1;we.forEach(function(C){if(C.sortableIndex!==ot(C)){T=!0;return}}),T&&a("update")}we.forEach(function(C){Oo(C)}),u.animateAll()}Rt=u}(o===s||c&&c.lastPutMode!=="clone")&&Et.forEach(function(C){C.parentNode&&C.parentNode.removeChild(C)})}},nullingGlobal:function(){this.isMultiDrag=Er=!1,Et.length=0},destroyGlobal:function(){this._deselectMultiDrag(),Te(document,"pointerup",this._deselectMultiDrag),Te(document,"mouseup",this._deselectMultiDrag),Te(document,"touchend",this._deselectMultiDrag),Te(document,"keydown",this._checkKeyDown),Te(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!(typeof Er<"u"&&Er)&&Rt===this.sortable&&!(t&&Ot(t.target,this.options.draggable,this.sortable.el,!1))&&!(t&&t.button!==0))for(;we.length;){var n=we[0];it(n,this.options.selectedClass,!1),we.shift(),Yr({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)}},Pt(r,{pluginName:"multiDrag",utils:{select:function(t){var n=t.parentNode[pt];!n||!n.options.multiDrag||~we.indexOf(t)||(Rt&&Rt!==n&&(Rt.multiDrag._deselectMultiDrag(),Rt=n),it(t,n.options.selectedClass,!0),we.push(t))},deselect:function(t){var n=t.parentNode[pt],o=we.indexOf(t);!n||!n.options.multiDrag||!~o||(it(t,n.options.selectedClass,!1),we.splice(o,1))}},eventProperties:function(){var t=this,n=[],o=[];return we.forEach(function(s){n.push({multiDragElement:s,index:s.sortableIndex});var i;xt&&s!==Ve?i=-1:xt?i=ot(s,":not(."+t.options.selectedClass+")"):i=ot(s),o.push({multiDragElement:s,index:i})}),{items:rh(we),clones:[].concat(Et),oldIndicies:n,newIndicies:o}},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 Dh(r,e){we.forEach(function(t,n){var o=e.children[t.sortableIndex+(r?Number(n):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function da(r,e){Et.forEach(function(t,n){var o=e.children[t.sortableIndex+(r?Number(n):0)];o?e.insertBefore(t,o):e.appendChild(t)})}function Pn(){we.forEach(function(r){r!==Ve&&r.parentNode&&r.parentNode.removeChild(r)})}ye.mount(new Ih);ye.mount(Xo,Ko);var fr=ye;var Aa={name:function(r,e){let t=r.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created:function(r,e){let t=Number(r.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated:function(r,e){let t=Number(r.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},ka={up:{active(r,e,t){return!(r.previousElementSibling===null&&!e)},run(r,e,t){(r.previousElementSibling||e).insertAdjacentElement("beforebegin",r)}},down:{active(r,e,t){return!(r.nextElementSibling===null&&!e)},run(r,e,t){(r.nextElementSibling||e).insertAdjacentElement("afterend",r)}},next_book:{active(r,e,t){return t.nextElementSibling!==null},run(r,e,t){t.nextElementSibling.querySelector("ul").prepend(r)}},prev_book:{active(r,e,t){return t.previousElementSibling!==null},run(r,e,t){t.previousElementSibling.querySelector("ul").appendChild(r)}},next_chapter:{active(r,e,t){return r.dataset.type==="page"&&this.getNextChapter(r,e)},run(r,e,t){this.getNextChapter(r,e).querySelector("ul").prepend(r)},getNextChapter(r,e){let t=e||r,n=Array.from(t.parentElement.children),o=n.indexOf(t);return n.slice(o+1).find(s=>s.dataset.type==="chapter")}},prev_chapter:{active(r,e,t){return r.dataset.type==="page"&&this.getPrevChapter(r,e)},run(r,e,t){this.getPrevChapter(r,e).querySelector("ul").append(r)},getPrevChapter(r,e){let t=e||r,n=Array.from(t.parentElement.children),o=n.indexOf(t);return n.slice(0,o).reverse().find(s=>s.dataset.type==="chapter")}},book_end:{active(r,e,t){return e||e===null&&r.nextElementSibling},run(r,e,t){t.querySelector("ul").append(r)}},book_start:{active(r,e,t){return e||e===null&&r.previousElementSibling},run(r,e,t){t.querySelector("ul").prepend(r)}},before_chapter:{active(r,e,t){return e},run(r,e,t){e.insertAdjacentElement("beforebegin",r)}},after_chapter:{active(r,e,t){return e},run(r,e,t){e.insertAdjacentElement("afterend",r)}}},Gn=class extends V{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input,fr.mount(new Sa);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",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let i=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");t=e===a?!t:!1;let l=Aa[a];t&&n.includes(a)&&(l=function(c,u){return 0-Aa[a](c,u)});for(let c of i)Array.from(c.children).filter(d=>d.matches("li")).sort(l).forEach(d=>{c.appendChild(d)});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(o=>{let s=tr(o.data);this.sortContainer.append(s),this.setupBookSortable(s),this.updateMoveActionStateForAll(),s.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"]},o={name:"chapter",pull:["book","chapter"],put:function(s,i,a){return a.getAttribute("data-type")==="page"}};for(let s of t)fr.create(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:i=>{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 o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(i=>i.matches('[data-type="page"], [data-type="chapter"]'));for(let i=0;i<s.length;i++)this.addBookChildToMap(s[i],i,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),i=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:i,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)o.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]"),o=e.parentElement.closest('[data-type="book"]');ka[t].run(e,n,o),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[o,s]of Object.entries(ka)){let i=e.querySelector(`[data-move="${o}"]`);i.disabled=!s.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 Wn=new WeakMap;function Ta(r,e=400,t=null){an(r),r.style.display="block",sn(r,{opacity:["0","1"]},e,()=>{t&&t()})}function Yn(r,e=400,t=null){an(r),sn(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function Tr(r,e=400){an(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[o,"0px"],paddingBottom:[s,"0px"]};sn(r,i,e,()=>{r.style.display="none"})}function Ir(r,e=400){an(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",o],paddingBottom:["0px",s]};sn(r,i,e)}function Ia(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{an(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,c]};sn(r,u,e)}}function sn(r,e,t=400,n=null){let o=Object.keys(e);for(let i of o)r.style[i]=e[i][0];let s=()=>{for(let i of o)r.style[i]=null;r.style.transition=null,r.removeEventListener("transitionend",s),Wn.delete(r),n&&n()};setTimeout(()=>{r.style.transition=`all ease-in-out ${t}ms`;for(let i of o)r.style[i]=e[i][1];r.addEventListener("transitionend",s),Wn.set(r,s)},15)}function an(r){Wn.has(r)&&Wn.get(r)()}var Kn=class extends V{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"),Ir(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),Tr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Xn=class extends V{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.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),je(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),xn(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),je(this.saveButton,e=>this.save()),We(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let t=e.dataset.lang,n=this.favourites.has(t);e.setAttribute("data-favourite",n?"true":"false"),We(e.parentElement,".lang-option-favorite-toggle","click",()=>{n=!n,n?this.favourites.add(t):this.favourites.delete(t),e.setAttribute("data-favourite",n?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:t,active:n}),this.sortLanguageList(),n&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((t,n)=>{let o=t.dataset.favourite==="true",s=n.dataset.favourite==="true";return o&&!s?-1:s&&!o||t.dataset.lang>n.dataset.lang?1:-1}).map(t=>t.parentElement);for(let t of e)this.languageOptionsContainer.append(t)}save(){this.callback&&this.callback(this.editor.getValue(),this.languageInput.value),this.hide()}open(e,t,n){this.languageInput.value=t,this.callback=n,this.show().then(()=>this.languageInputChange(t)).then(()=>window.importVersioned("code")).then(o=>o.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase();for(let n of this.languageButtons){let o=n.dataset.lang.toLowerCase().trim(),s=t===o;n.classList.toggle("active",s),s&&n.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}};var Zn=class extends V{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var Qn=class extends V{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var Jn=class extends V{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"),Ir(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),Tr(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var ei=class extends V{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,je(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var ti=class extends V{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 ri=class extends V{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 ni=class extends V{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,o=this.toggle.getBoundingClientRect().height,s=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`,n=s?window.innerHeight-t.top-o/2:t.top),s?(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 i=this.menu.querySelector("input");i!==null&&i.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 rr(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()}),je(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var ii=class extends V{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=Bt(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 o=!e||n.textContent.toLowerCase().includes(e);n.style.display=o?"flex":"none",n.classList.toggle("hidden",!o)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=Ia(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 La=gn(Da());var si=class extends V{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new La.default(this.container,{addRemoveLinks:!0,dictRemoveFile:this.removeMessage,timeout:Number(window.uploadTimeout)||6e4,maxFilesize:this.uploadLimit,url:this.url,withCredentials:!0,init(){this.dz=this,this.dz.on("sending",e.onSending.bind(e)),this.dz.on("success",e.onSuccess.bind(e)),this.dz.on("error",e.onError.bind(e))}})}onSending(e,t,n){let o=window.document.querySelector("meta[name=token]").getAttribute("content");n.append("_token",o),t.ontimeout=s=>{this.dz.emit("complete",e),this.dz.emit("error",e,this.timeoutMessage)}}onSuccess(e,t){this.$emit("success",{file:e,data:t}),this.successMessage&&window.$events.emit("success",this.successMessage),Yn(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let o=s=>{let i=e.previewElement.querySelector("[data-dz-errormessage]");i.textContent=s};n&&n.status===413?o(this.uploadLimitMessage):t.file&&o(t.file)}removeAll(){this.dz.removeAllFiles(!0)}};var ai=class extends V{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 li=class extends V{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 o of n)o.disabled=t,o.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",e=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}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}`),o=tr(n.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),n=e.dataset.roleId,o=e.dataset.roleName,s=document.createElement("option");s.value=n,s.textContent=o,this.roleSelect.append(s),t.remove()}};var ci=class extends V{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()}),je(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();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 ui=class extends V{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",t=>{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()}),We(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.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),o=t[n+(e?1:-1)]||t[0];o&&o.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"),o=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${o}`:"";let i=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:i};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&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 di=class extends V{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 hi=class extends V{setup(){this.container=this.$el,this.name=this.$opts.name,je(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var fi=class extends V{setup(e){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){Ir(e,200)}close(e){Tr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var pi=class extends V{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=Bt(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let t=this.input.value;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 rr(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=tr(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 mi=class extends V{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 gi=class extends V{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.formContainer=this.$refs.formContainer,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(){je(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()}),je(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),We(this.listContainer,".load-more","click",async e=>{zr(e.target),this.page++,await this.loadGallery(),e.target.remove()}),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",e=>{e.target.src=baseUrl("loading_error.png")},!0),je(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),We(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),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),Qs(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e,window.$components.init(t);for(let n of[...t.children])this.listContainer.appendChild(n)}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=""}resetEditForm(){this.formContainer.innerHTML=""}resetListView(){zr(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,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),o?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",o),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:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,window.$components.init(this.formContainer)}};var vi=class extends V{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 yi=class extends V{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 ju=gn($u()),Hu=gn(zu()),Oi=class{constructor(){this.renderer=new ju.default({html:!0}),this.renderer.use(Hu.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Jp(r,e){return document.createElement(r,e)}function em(r,e,t){return document.createElementNS(r,e,t)}function tm(){return gr(document.createDocumentFragment())}function rm(r){return document.createTextNode(r)}function nm(r){return document.createComment(r)}function im(r,e,t){if(Zt(r)){let n=r;for(;n&&Zt(n);)n=gr(n).parent;r=n??r}Zt(e)&&(e=gr(e,r)),t&&Zt(t)&&(t=gr(t).firstChildNode),r.insertBefore(e,t)}function om(r,e){r.removeChild(e)}function sm(r,e){Zt(e)&&(e=gr(e,r)),r.appendChild(e)}function Vu(r){if(Zt(r)){for(;r&&Zt(r);)r=gr(r).parent;return r??null}return r.parentNode}function am(r){var e;if(Zt(r)){let t=gr(r),n=Vu(t);if(n&&t.lastChildNode){let o=Array.from(n.childNodes),s=o.indexOf(t.lastChildNode);return(e=o[s+1])!==null&&e!==void 0?e:null}return null}return r.nextSibling}function lm(r){return r.tagName}function cm(r,e){r.textContent=e}function um(r){return r.textContent}function dm(r){return r.nodeType===1}function hm(r){return r.nodeType===3}function fm(r){return r.nodeType===8}function Zt(r){return r.nodeType===11}function gr(r,e){var t,n,o;let s=r;return(t=s.parent)!==null&&t!==void 0||(s.parent=e??null),(n=s.firstChildNode)!==null&&n!==void 0||(s.firstChildNode=r.firstChild),(o=s.lastChildNode)!==null&&o!==void 0||(s.lastChildNode=r.lastChild),s}var Pi={createElement:Jp,createElementNS:em,createTextNode:rm,createDocumentFragment:tm,createComment:nm,insertBefore:im,removeChild:om,appendChild:sm,parentNode:Vu,nextSibling:am,tagName:lm,setTextContent:cm,getTextContent:um,isElement:dm,isText:hm,isComment:fm,isDocumentFragment:Zt};function Qt(r,e,t,n,o){let s=e===void 0?void 0:e.key;return{sel:r,data:e,children:t,text:n,elm:o,key:s}}var qu=Array.isArray;function Gu(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function Is(r){return r===void 0}function wt(r){return r!==void 0}var Ds=Qt("",{},[],void 0,void 0);function hn(r,e){var t,n;let o=r.key===e.key,s=((t=r.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is),i=r.sel===e.sel,a=!r.sel&&r.sel===e.sel?typeof r.text==typeof e.text:!0;return i&&o&&s&&a}function mm(){throw new Error("The document fragment is not supported on this platform.")}function gm(r,e){return r.isElement(e)}function vm(r,e){return r.isDocumentFragment(e)}function ym(r,e,t){var n;let o={};for(let s=e;s<=t;++s){let i=(n=r[s])===null||n===void 0?void 0:n.key;i!==void 0&&(o[i]=s)}return o}var bm=["create","update","remove","destroy","pre","post"];function Ls(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:Pi;for(let p of bm)for(let v of r){let y=v[p];y!==void 0&&n[p].push(y)}function s(p){let v=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return Qt(o.tagName(p).toLowerCase()+v+b,{},[],void 0,p)}function i(p){return Qt(void 0,{},[],void 0,p)}function a(p,v){return function(){if(--v===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,v){var y,b,x,T;let C,M=p.data;if(M!==void 0){let A=(y=M.hook)===null||y===void 0?void 0:y.init;wt(A)&&(A(p),M=p.data)}let S=p.children,O=p.sel;if(O==="!")Is(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(O!==void 0){let A=O.indexOf("#"),D=O.indexOf(".",A),I=A>0?A:O.length,P=D>0?D:O.length,_=A!==-1||D!==-1?O.slice(0,Math.min(I,P)):O,B=p.elm=wt(M)&&wt(C=M.ns)?o.createElementNS(C,_,M):o.createElement(_,M);for(I<P&&B.setAttribute("id",O.slice(I+1,P)),D>0&&B.setAttribute("class",O.slice(P+1).replace(/\./g," ")),C=0;C<n.create.length;++C)n.create[C](Ds,p);if(qu(S))for(C=0;C<S.length;++C){let Q=S[C];Q!=null&&o.appendChild(B,l(Q,v))}else Gu(p.text)&&o.appendChild(B,o.createTextNode(p.text));let H=p.data.hook;wt(H)&&((b=H.create)===null||b===void 0||b.call(H,Ds,p),H.insert&&v.push(p))}else if(!((x=t?.experimental)===null||x===void 0)&&x.fragments&&p.children){for(p.elm=((T=o.createDocumentFragment)!==null&&T!==void 0?T:mm)(),C=0;C<n.create.length;++C)n.create[C](Ds,p);for(C=0;C<p.children.length;++C){let A=p.children[C];A!=null&&o.appendChild(p.elm,l(A,v))}}else p.elm=o.createTextNode(p.text);return p.elm}function c(p,v,y,b,x,T){for(;b<=x;++b){let C=y[b];C!=null&&o.insertBefore(p,l(C,T),v)}}function u(p){var v,y;let b=p.data;if(b!==void 0){(y=(v=b?.hook)===null||v===void 0?void 0:v.destroy)===null||y===void 0||y.call(v,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let T=p.children[x];T!=null&&typeof T!="string"&&u(T)}}}function d(p,v,y,b){for(var x,T;y<=b;++y){let C,M,S=v[y];if(S!=null)if(wt(S.sel)){u(S),C=n.remove.length+1,M=a(S.elm,C);for(let A=0;A<n.remove.length;++A)n.remove[A](S,M);let O=(T=(x=S?.data)===null||x===void 0?void 0:x.hook)===null||T===void 0?void 0:T.remove;wt(O)?O(S,M):M()}else S.children?(u(S),d(p,S.children,0,S.children.length-1)):o.removeChild(p,S.elm)}}function h(p,v,y,b){let x=0,T=0,C=v.length-1,M=v[0],S=v[C],O=y.length-1,A=y[0],D=y[O],I,P,_,B;for(;x<=C&&T<=O;)M==null?M=v[++x]:S==null?S=v[--C]:A==null?A=y[++T]:D==null?D=y[--O]:hn(M,A)?(f(M,A,b),M=v[++x],A=y[++T]):hn(S,D)?(f(S,D,b),S=v[--C],D=y[--O]):hn(M,D)?(f(M,D,b),o.insertBefore(p,M.elm,o.nextSibling(S.elm)),M=v[++x],D=y[--O]):hn(S,A)?(f(S,A,b),o.insertBefore(p,S.elm,M.elm),S=v[--C],A=y[++T]):(I===void 0&&(I=ym(v,x,C)),P=I[A.key],Is(P)?o.insertBefore(p,l(A,b),M.elm):(_=v[P],_.sel!==A.sel?o.insertBefore(p,l(A,b),M.elm):(f(_,A,b),v[P]=void 0,o.insertBefore(p,_.elm,M.elm))),A=y[++T]);T<=O&&(B=y[O+1]==null?null:y[O+1].elm,c(p,B,y,T,O,b)),x<=C&&d(p,v,x,C)}function f(p,v,y){var b,x,T,C,M,S,O,A;let D=(b=v.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,v);let I=v.elm=p.elm;if(p===v)return;if(v.data!==void 0||wt(v.text)&&v.text!==p.text){(T=v.data)!==null&&T!==void 0||(v.data={}),(C=p.data)!==null&&C!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,v);(O=(S=(M=v.data)===null||M===void 0?void 0:M.hook)===null||S===void 0?void 0:S.update)===null||O===void 0||O.call(S,p,v)}let P=p.children,_=v.children;Is(v.text)?wt(P)&&wt(_)?P!==_&&h(I,P,_,y):wt(_)?(wt(p.text)&&o.setTextContent(I,""),c(I,null,_,0,_.length-1,y)):wt(P)?d(I,P,0,P.length-1):wt(p.text)&&o.setTextContent(I,""):p.text!==v.text&&(wt(P)&&d(I,P,0,P.length-1),o.setTextContent(I,v.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,v)}return function(v,y){let b,x,T,C=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(gm(o,v)?v=s(v):vm(o,v)&&(v=i(v)),hn(v,y)?f(v,y,C):(x=v.elm,T=o.parentNode(x),l(y,C),T!==null&&(o.insertBefore(T,y.elm,o.nextSibling(x)),d(T,[v],0,0))),b=0;b<C.length;++b)C[b].data.hook.insert(C[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function Fs(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&Fs(s,o.children,o.sel)}}function fn(r,e){let t=e!==void 0?e:Pi,n;if(t.isElement(r)){let o=r.id?"#"+r.id:"",s=r.getAttribute("class"),i=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+o+i,l={},c={},u={},d=[],h,f,p,v=r.attributes,y=r.childNodes;for(f=0,p=v.length;f<p;f++)h=v[f].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?c[h.slice(5)]=v[f].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=v[f].nodeValue);for(f=0,p=y.length;f<p;f++)d.push(fn(y[f],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]==="#")&&Fs(u,d,a),Qt(a,u,d,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),Qt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),Qt("!",{},[],n,r)):Qt("",{},[],void 0,r)}var xm="http://www.w3.org/1999/xlink",wm="http://www.w3.org/XML/1998/namespace";function Wu(r,e){let t,n=e.elm,o=r.data.attrs,s=e.data.attrs;if(!(!o&&!s)&&o!==s){o=o||{},s=s||{};for(t in s){let i=s[t];o[t]!==i&&(i===!0?n.setAttribute(t,""):i===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,i):t.charCodeAt(3)===58?n.setAttributeNS(wm,t,i):t.charCodeAt(5)===58?n.setAttributeNS(xm,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var Rs={create:Wu,update:Wu};var Mi;function Cm(){return Mi||(Mi=Ls([Rs]),Mi)}function Yu(r,e){let t=document.createElement("div");t.innerHTML=e,Cm()(fn(r),fn(t))}var $i=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 o=e.target.closest("[drawio-diagram]");if(o!==null&&t){this.editor.actions.editDrawing(o);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 t=this.doc.body;if(t.children.length===0){let o=document.createElement("div");this.doc.body.append(o)}let n=t.children[0];Yu(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 Vt=null,Ms,Os,Ps;function Em(r,e,t){Os=e,Ps=t,Vt=document.createElement("iframe"),Vt.setAttribute("frameborder","0"),window.addEventListener("message",Xu),Vt.setAttribute("src",r),Vt.setAttribute("class","fullscreen"),Vt.style.backgroundColor="#FFFFFF",document.body.appendChild(Vt),Ms=new URL(r).origin}function Ku(){Zu()}function Xu(r){if(!r.data||r.data.length<1||r.origin!==Ms)return;let e=JSON.parse(r.data);e.event==="init"?km():e.event==="exit"?Zu():e.event==="save"?Am(e):e.event==="export"?Sm(e):e.event==="configure"&&Tm()}function Sm(r){Ps&&Ps(r.data)}function Am(r){$s({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function km(){Os&&Os().then(r=>{$s({action:"load",autosave:1,xml:r})})}function Tm(){let r={};window.$events.emitPublic(Vt,"editor-drawio::configure",{config:r}),$s({action:"configure",config:r})}function Zu(){window.removeEventListener("message",Xu),Vt&&document.body.removeChild(Vt)}function $s(r){Vt.contentWindow.postMessage(JSON.stringify(r),Ms)}async function Im(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function Dm(r){try{return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}catch(e){throw e instanceof window.$http.HttpError&&window.$events.showResponseError(e),Ku(),e}}var kt={show:Em,close:Ku,upload:Im,load:Dm};var _i=class{constructor(e){this.editor=e,this.lastContent={html:"",markdown:""}}updateAndRender(){let e=this.editor.cm.getValue();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}insertImage(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{let o=n.thumbs.display||n.url,i="[]("+n.url+")";this.editor.cm.focus(),this.editor.cm.replaceSelection(i),this.editor.cm.setCursor(e.line,e.ch+i.length)},"gallery")}insertLink(){let e=this.editor.cm.getCursor("from"),t=this.editor.cm.getSelection()||"",n=`[${t}]()`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n);let o=t===""?-3:-1;this.editor.cm.setCursor(e.line,e.ch+n.length+o)}showImageManager(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{this.insertDrawing(n,e)},"drawio")}showLinkSelector(){let e=this.editor.cm.getCursor("from");window.$components.first("entity-selector-popup").show(n=>{let s=`[${this.editor.cm.getSelection()||n.name}](${n.link})`;this.editor.cm.focus(),this.editor.cm.replaceSelection(s),this.editor.cm.setCursor(e.line,e.ch+s.length)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=this.editor.cm.getCursor("from");kt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),kt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n),this.editor.cm.setCursor(t.line,t.ch+n.length)}editDrawing(e){let t=this.editor.config.drawioUrl;if(!t)return;let n=this.editor.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");kt.show(t,()=>kt.load(o),s=>{let i={image:s,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=this.editor.cm.getValue().split(`
+`).map(u=>u.indexOf(`drawio-diagram="${o}"`)!==-1?l:u).join(`
+`);this.editor.cm.setValue(c),this.editor.cm.setCursor(n),this.editor.cm.focus(),kt.close()}).catch(a=>{this.handleDrawingUploadError(a)})})}handleDrawingUploadError(e){e.status===413?window.$events.emit("error",this.editor.config.text.serverUploadLimit):window.$events.emit("error",this.editor.config.text.imageUploadError),console.log(e)}fullScreen(){let e=this.editor.config.container,t=e.classList.contains("fullscreen");e.classList.toggle("fullscreen",!t),document.body.classList.toggle("markdown-fullscreen",!t)}scrollToText(e){if(!e)return;let n=this.editor.cm.getValue().split(/\r?\n/),o=n.findIndex(s=>s&&s.indexOf(e)!==-1);o!==-1&&(this.editor.cm.scrollIntoView({line:o},200),this.editor.cm.focus(),this.editor.cm.setCursor({line:o,char:n[o].length}))}focus(){this.editor.cm.focus()}insertContent(e){this.editor.cm.replaceSelection(e)}prependContent(e){let t=this.editor.cm.getCursor("from"),n=e+`
+`+this.editor.cm.getValue();this.editor.cm.setValue(n);let o=e.split(`
+`).length;this.editor.cm.setCursor(t.line+o,t.ch)}appendContent(e){let t=this.editor.cm.getCursor("from"),n=this.editor.cm.getValue()+`
+`+e;this.editor.cm.setValue(n),this.editor.cm.setCursor(t.line,t.ch)}replaceContent(e){this.editor.cm.setValue(e)}findAndReplaceContent(e,t){let n=this.editor.cm.getValue(),o=this.editor.cm.listSelections();this.editor.cm.setValue(n.replace(e,t)),this.editor.cm.setSelections(o)}replaceLineStart(e){let t=this.editor.cm.getCursor(),n=this.editor.cm.getLine(t.line),o=n.length,s=n.split(" ")[0];if(s===e){n=n.replace(`${e} `,""),this.editor.cm.replaceRange(n,{line:t.line,ch:0},{line:t.line,ch:o}),this.editor.cm.setCursor({line:t.line,ch:t.ch-(e.length+1)});return}let i=/^[#>`]/.test(s),a=0;i?(a=e.length-s.length,n=n.replace(s,e).trim()):e!==""&&(a=e.length+1,n=e+" "+n),this.editor.cm.replaceRange(n,{line:t.line,ch:0},{line:t.line,ch:o}),this.editor.cm.setCursor({line:t.line,ch:t.ch+a})}wrapLine(e,t){let n=this.editor.cm.getCursor(),o=this.editor.cm.getLine(n.line),s=o.length,i=o;o.indexOf(e)===0&&o.slice(-t.length)===t?i=o.slice(e.length,o.length-t.length):i=`${e}${o}${t}`,this.editor.cm.replaceRange(i,{line:n.line,ch:0},{line:n.line,ch:s}),this.editor.cm.setCursor({line:n.line,ch:n.ch+e.length})}wrapSelection(e,t){let n=this.editor.cm.getSelection();if(n==="")return this.wrapLine(e,t);let o=n,s=0,i;n.indexOf(e)===0&&n.slice(-t.length)===t?(o=n.slice(e.length,n.length-t.length),i=-(t.length+e.length)):(o=`${e}${n}${t}`,i=e.length+t.length);let a=this.editor.cm.listSelections()[0];this.editor.cm.replaceSelection(o);let l=a.head.ch<=a.anchor.ch;a.head.ch+=l?s:i,a.anchor.ch+=l?i:s,this.editor.cm.setSelections([a])}replaceLineStartForOrderedList(){let e=this.editor.cm.getCursor(),n=(this.editor.cm.getLine(e.line-1)||"").match(/^(\s*)(\d)([).])\s/)||[],o=(Number(n[2])||0)+1,s=n[1]||"",i=n[3]||".",a=`${s}${o}${i}`;return this.replaceLineStart(a)}cycleCalloutTypeAtSelection(){let e=this.editor.cm.listSelections()[0],t=this.editor.cm.getLine(e.anchor.line),n=t.length,o={anchor:{line:e.anchor.line,ch:0},head:{line:e.anchor.line,ch:n}},s=["info","success","warning","danger"],i=s.join("|"),l=new RegExp(`class="((${i})\\s+callout|callout\\s+(${i}))"`,"i").exec(t),c=(l?l[2]||l[3]:"").toLowerCase();if(c===s[s.length-1])this.wrapLine(`<p class="callout ${s[s.length-1]}">`,"</p>");else if(c==="")this.wrapLine('<p class="callout info">',"</p>");else{let u=s.indexOf(c)+1,d=s[u],h=t.replace(l[0],l[0].replace(c,d));this.editor.cm.replaceRange(h,o.anchor,o.head);let f=h.length-t.length;e.anchor.ch+=f,e.anchor!==e.head&&(e.head.ch+=f),this.editor.cm.setSelection(e.anchor,e.head)}}uploadImage(e){if(e===null||e.type.indexOf("image")!==0)return;let t="png";if(e.name){let u=e.name.match(/\.(.+)$/);u.length>1&&(t=u[1])}let n="image-"+Math.random().toString(16).slice(2),o=window.baseUrl(`/loading.gif#upload${n}`),s=this.editor.cm.getSelection(),i=``,a=this.editor.cm.getCursor();this.editor.cm.replaceSelection(i),this.editor.cm.setCursor({line:a.line,ch:a.ch+s.length+3});let l="image-"+Date.now()+"."+t,c=new FormData;c.append("file",e,l),c.append("uploaded_to",this.editor.config.pageId),window.$http.post("/images/gallery",c).then(u=>{let d=`[](${u.data.url})`;this.findAndReplaceContent(i,d)}).catch(u=>{window.$events.emit("error",this.editor.config.text.imageUploadError),this.findAndReplaceContent(i,s),console.log(u)})}syncDisplayPosition(){let e=this.editor.cm.getScrollInfo();if(e.top+e.clientHeight===e.height){this.editor.display.scrollToIndex(-1);return}let n=this.editor.cm.lineAtHeight(e.top,"local"),o=this.editor.cm.getRange({line:0,ch:null},{line:n,ch:null}),a=new DOMParser().parseFromString(this.editor.markdown.render(o),"text/html").documentElement.querySelectorAll("body > *");this.editor.display.scrollToIndex(a.length)}insertTemplate(e,t,n){let o=this.editor.cm.coordsChar({left:t,top:n});this.editor.cm.setCursor(o),window.$http.get(`/templates/${e}`).then(s=>{let i=s.data.markdown||s.data.html;this.editor.cm.replaceSelection(i)})}insertClipboardImages(e){let t=this.editor.cm.coordsChar({left:event.pageX,top:event.pageY});this.editor.cm.setCursor(t);for(let n of e)this.uploadImage(n)}};var Bi=class{constructor(e){this.settingMap={scrollSync:!0,showPreview:!0,editorWidth:50},this.changeListeners={},this.loadFromLocalStorage(),this.applyToInputs(e),this.listenToInputChanges(e)}applyToInputs(e){for(let t of e){let n=t.getAttribute("name").replace("md-","");t.checked=this.settingMap[n]}}listenToInputChanges(e){for(let t of e)t.addEventListener("change",n=>{let o=t.getAttribute("name").replace("md-","");this.set(o,t.checked)})}loadFromLocalStorage(){let e=window.localStorage.getItem("md-editor-settings");if(!e)return;let t=JSON.parse(e);for(let[n,o]of Object.entries(t))o!==null&&this.settingMap[n]!==void 0&&(this.settingMap[n]=o)}set(e,t){this.settingMap[e]=t,window.localStorage.setItem("md-editor-settings",JSON.stringify(this.settingMap));for(let n of this.changeListeners[e]||[])n(t)}get(e){return this.settingMap[e]||null}onChange(e,t){let n=this.changeListeners[e]||[];n.push(t),this.changeListeners[e]=n}};function Ni({html:r,markdown:e}){return e||r}function Qu(r){window.$events.listen("editor::replace",e=>{let t=Ni(e);r.actions.replaceContent(t)}),window.$events.listen("editor::append",e=>{let t=Ni(e);r.actions.appendContent(t)}),window.$events.listen("editor::prepend",e=>{let t=Ni(e);r.actions.prependContent(t)}),window.$events.listen("editor::insert",e=>{let t=Ni(e);r.actions.insertContent(t)}),window.$events.listen("editor::focus",()=>{r.actions.focus()})}function Ju(r,e){let t={};return t[`${e}-Alt-I`]=function(n){let s=``,i=n.getCursor("from");n.replaceSelection(s),n.setCursor(i.line,i.ch+s.length-1)},t[`${e}-S`]=n=>window.$events.emit("editor-save-draft"),t[`${e}-Enter`]=n=>window.$events.emit("editor-save-page"),t[`Shift-${e}-K`]=n=>r.actions.showLinkSelector(),t[`${e}-K`]=n=>r.actions.insertLink(),t[`${e}-1`]=n=>r.actions.replaceLineStart("##"),t[`${e}-2`]=n=>r.actions.replaceLineStart("###"),t[`${e}-3`]=n=>r.actions.replaceLineStart("####"),t[`${e}-4`]=n=>r.actions.replaceLineStart("#####"),t[`${e}-5`]=n=>r.actions.replaceLineStart(""),t[`${e}-D`]=n=>r.actions.replaceLineStart(""),t[`${e}-6`]=n=>r.actions.replaceLineStart(">"),t[`${e}-Q`]=n=>r.actions.replaceLineStart(">"),t[`${e}-7`]=n=>r.actions.wrapSelection("\n```\n","\n```"),t[`${e}-8`]=n=>r.actions.wrapSelection("`","`"),t[`Shift-${e}-E`]=n=>r.actions.wrapSelection("`","`"),t[`${e}-9`]=n=>r.actions.cycleCalloutTypeAtSelection(),t[`${e}-P`]=n=>r.actions.replaceLineStart("-"),t[`${e}-O`]=n=>r.actions.replaceLineStartForOrderedList(),t}var _s=class{constructor(e){this.data=e}hasItems(){return Boolean(this.data)&&Boolean(this.data.types)&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let e=this.data.types,t=this.data.files,n=[];for(let o of e)if(o.includes("image")){let s=this.data.getData(o);n.push(s.getAsFile())}for(let o of t)o.type.includes("image")&&n.push(o);return n}},pn=_s;async function ed(r){let e=await window.importVersioned("code"),t=e.markdownEditor(r.config.inputEl);t.setOption("direction","ltr"),t.setOption("extraKeys",Ju(r,e.getMetaKey())),t.on("change",(s,i)=>r.actions.updateAndRender());let n=Bt(r.actions.syncDisplayPosition.bind(r.actions),100,!1),o=r.settings.get("scrollSync");return r.settings.onChange("scrollSync",s=>o=s),t.on("scroll",s=>{o&&n(s)}),t.on("paste",(s,i)=>{let a=new pn(i.clipboardData||i.dataTransfer);if(!a.hasItems()||a.containsTabularData())return;let l=a.getImages();for(let c of l)r.actions.uploadImage(c)}),t.on("drop",(s,i)=>{let a=i.dataTransfer.getData("bookstack/template");a&&(i.preventDefault(),r.actions.insertTemplate(a,i.pageX,i.pageY));let c=new pn(i.dataTransfer).getImages();c.length>0&&(i.stopPropagation(),i.preventDefault(),r.actions.insertClipboardImages(c))}),t}async function td(r){let e={config:r,markdown:new Oi,settings:new Bi(r.settingInputs)};return e.actions=new _i(e),e.display=new $i(e),e.cm=await ed(e),Qu(e),e}var Ui=class extends V{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.display=this.$refs.display,this.input=this.$refs.input,this.divider=this.$refs.divider,this.displayWrap=this.$refs.displayWrap;let t=this.$refs.settingContainer.querySelectorAll('input[type="checkbox"]');this.editor=null,td({pageId:this.pageId,container:this.elem,displayEl:this.display,inputEl:this.input,drawioUrl:this.getDrawioUrl(),settingInputs:Array.from(t),text:{serverUploadLimit:this.serverUploadLimitText,imageUploadError:this.imageUploadErrorText}}).then(n=>{this.editor=n,this.setupListeners(),this.emitEditorEvents(),this.scrollToTextIfNeeded(),this.editor.actions.updateAndRender()})}emitEditorEvents(){window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.editor.markdown.getRenderer(),displayEl:this.display,codeMirrorInstance:this.editor.cm})}setupListeners(){this.elem.addEventListener("click",n=>{let o=n.target.closest("button[data-action]");if(o===null)return;let s=o.getAttribute("data-action");if(s==="insertImage"&&this.editor.actions.insertImage(),s==="insertLink"&&this.editor.actions.showLinkSelector(),s==="insertDrawing"&&(n.ctrlKey||n.metaKey)){this.editor.actions.showImageManager();return}s==="insertDrawing"&&this.editor.actions.startDrawing(),s==="fullscreen"&&this.editor.actions.fullScreen()}),this.elem.addEventListener("click",n=>{let o=n.target.closest(".editor-toolbar-label");if(!o)return;let s=this.elem.querySelectorAll(".markdown-editor-wrap");for(let i of s)i.classList.remove("active");o.closest(".markdown-editor-wrap").classList.add("active")});let e=Bt(()=>this.editor.cm.refresh(),100,!1);new ResizeObserver(e).observe(this.elem),this.handleDividerDrag()}handleDividerDrag(){this.divider.addEventListener("pointerdown",t=>{let n=this.elem.getBoundingClientRect(),o=i=>{let a=i.pageX-n.left,l=Math.min(Math.max(20,Math.floor(a/n.width*100)),80);this.displayWrap.style.flexBasis=`${100-l}%`,this.editor.settings.set("editorWidth",l)},s=i=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",s),this.display.style.pointerEvents=null,document.body.style.userSelect=null,this.editor.cm.refresh()};this.display.style.pointerEvents="none",document.body.style.userSelect="none",window.addEventListener("pointermove",o),window.addEventListener("pointerup",s)});let e=this.editor.settings.get("editorWidth");e&&(this.displayWrap.style.flexBasis=`${100-e}%`)}scrollToTextIfNeeded(){let t=new URL(window.location).searchParams.get("content-text");t&&this.editor.actions.scrollToText(t)}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e&&e.getAttribute("drawio-url")||""}getContent(){return this.editor.actions.getContent()}};var zi=class extends V{setup(){this.container=this.$el,this.inputContainer=this.$refs.inputContainer,this.inviteOption=this.container.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let e=this.inviteOption.value==="true",t=this.container.querySelectorAll("input[type=password]");for(let n of t)n.disabled=e;this.inputContainer.style.display=e?"none":"block"}};var ji=class extends V{setup(){this.container=this.$el,this.type=this.$opts.type,this.textElem=this.container.querySelector("span"),this.autoHide=this.$opts.autoHide==="true",this.initialShow=this.$opts.show==="true",this.container.style.display="grid",window.$events.listen(this.type,e=>{this.show(e)}),this.container.addEventListener("click",this.hide.bind(this)),this.initialShow&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(e=""){if(this.container.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=e,this.container.style.display="grid",setTimeout(()=>{this.container.classList.add("showing")},1),this.autoHide){let t=e.split(" ").length,n=Math.max(2e3,1e3+250*t);setTimeout(this.hide.bind(this),n)}}hide(){this.container.classList.remove("showing"),this.container.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.container.style.display="none",this.container.removeEventListener("transitionend",this.hideCleanup)}};var Hi=class extends V{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){je(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),je(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}};var Vi=class extends V{setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.formContainer=this.$refs.formContainer,this.commentCountBar=this.$refs.commentCountBar,this.addButtonContainer=this.$refs.addButtonContainer,this.replyToRow=this.$refs.replyToRow,this.updatedText=this.$opts.updatedText,this.deletedText=this.$opts.deletedText,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.editingComment=null,this.parentId=null,this.formContainer&&(this.form=this.formContainer.querySelector("form"),this.formInput=this.form.querySelector("textarea"),this.form.addEventListener("submit",this.saveComment.bind(this))),this.elem.addEventListener("click",this.handleAction.bind(this)),this.elem.addEventListener("submit",this.updateComment.bind(this))}handleAction(e){let t=e.target.closest("[action]");if(e.target.matches('a[href^="#"]')){let s=e.target.href.split("#")[1];jr(document.querySelector("#"+s))}if(t===null)return;e.preventDefault();let n=t.getAttribute("action"),o=t.closest("[comment]");n==="edit"&&this.editComment(o),n==="closeUpdateForm"&&this.closeUpdateForm(),n==="delete"&&this.deleteComment(o),n==="addComment"&&this.showForm(),n==="hideForm"&&this.hideForm(),n==="reply"&&this.setReply(o),n==="remove-reply-to"&&this.removeReplyTo()}closeUpdateForm(){this.editingComment&&(this.editingComment.querySelector("[comment-content]").style.display="block",this.editingComment.querySelector("[comment-edit-container]").style.display="none")}editComment(e){this.hideForm(),this.editingComment&&this.closeUpdateForm(),e.querySelector("[comment-content]").style.display="none",e.querySelector("[comment-edit-container]").style.display="block";let t=e.querySelector("[comment-edit-container] textarea"),n=t.value.split(`
+`).length;t.style.height=n*20+40+"px",this.editingComment=e}updateComment(e){let t=e.target;e.preventDefault();let o={text:t.querySelector("textarea").value,parent_id:this.parentId||null};this.showLoading(t);let s=this.editingComment.getAttribute("comment");window.$http.put(`/comment/${s}`,o).then(i=>{let a=document.createElement("div");a.innerHTML=i.data,this.editingComment.innerHTML=a.children[0].innerHTML,window.$events.success(this.updatedText),window.$components.init(this.editingComment),this.closeUpdateForm(),this.editingComment=null}).catch(window.$events.showValidationErrors).then(()=>{this.hideLoading(t)})}deleteComment(e){let t=e.getAttribute("comment");this.showLoading(e.querySelector("[comment-content]")),window.$http.delete(`/comment/${t}`).then(n=>{e.parentNode.removeChild(e),window.$events.success(this.deletedText),this.updateCount(),this.hideForm()})}saveComment(e){e.preventDefault(),e.stopPropagation();let n={text:this.formInput.value,parent_id:this.parentId||null};this.showLoading(this.form),window.$http.post(`/comment/${this.pageId}`,n).then(o=>{let s=tr(o.data);this.container.appendChild(s),window.$components.init(s),window.$events.success(this.createdText),this.resetForm(),this.updateCount()}).catch(o=>{window.$events.showValidationErrors(o),this.hideLoading(this.form)})}updateCount(){let e=this.container.children.length;this.elem.querySelector("[comments-title]").textContent=window.trans_plural(this.countText,e,{count:e})}resetForm(){this.formInput.value="",this.formContainer.appendChild(this.form),this.hideForm(),this.removeReplyTo(),this.hideLoading(this.form)}showForm(){this.formContainer.style.display="block",this.formContainer.parentNode.style.display="block",this.addButtonContainer.style.display="none",this.formInput.focus(),this.formInput.scrollIntoView({behavior:"smooth"})}hideForm(){this.formContainer.style.display="none",this.formContainer.parentNode.style.display="none",this.getCommentCount()>0?this.elem.appendChild(this.addButtonContainer):this.commentCountBar.appendChild(this.addButtonContainer),this.addButtonContainer.style.display="block"}getCommentCount(){return this.elem.querySelectorAll(".comment-box[comment]").length}setReply(e){this.showForm(),this.parentId=Number(e.getAttribute("local-id")),this.replyToRow.style.display="block";let t=this.replyToRow.querySelector("a");t.textContent=`#${this.parentId}`,t.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.style.display="none"}showLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="none";e.querySelector(".form-group.loading").style.display="block"}hideLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="block";e.querySelector(".form-group.loading").style.display="none"}};var qi=class extends V{setup(){if(this.container=this.$el,this.pageId=this.$opts.pageId,window.importVersioned("code").then(t=>t.highlight()),this.setupNavHighlighting(),this.setupDetailsCodeBlockRefresh(),window.location.hash){let t=window.location.hash.replace(/%20/g," ").substring(1);this.goToText(t)}let e=document.querySelector(".sidebar-page-nav");e&&We(e,"a","click",(t,n)=>{t.preventDefault(),window.$components.first("tri-layout").showContent();let o=n.getAttribute("href").substr(1);this.goToText(o),window.history.pushState(null,null,"#"+o)})}goToText(e){let t=document.getElementById(e);if(To(".page-content [data-highlighted]",n=>{n.removeAttribute("data-highlighted"),n.style.backgroundColor=null}),t!==null)jr(t);else{let n=Zs(".page-content > div > *",e);n&&jr(n)}}setupNavHighlighting(){let e=document.querySelector(".sidebar-page-nav"),t=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");t.length>0&&e!==null&&n(t);function n(i){let a={rootMargin:"0px 0px 0px 0px",threshold:1},l=new IntersectionObserver(o,a);for(let c of i)l.observe(c)}function o(i,a){for(let l of i){let c=l.intersectionRatio===1;s(l.target.id,c)}}function s(i,a){To('a[href="#'+i+'"]',l=>{l.closest("li").classList.toggle("current-heading",a)})}}setupDetailsCodeBlockRefresh(){let e=n=>{[...n.target.querySelectorAll(".CodeMirror")].forEach(s=>s.CodeMirror&&s.CodeMirror.refresh())};[...this.container.querySelectorAll("details")].forEach(n=>n.addEventListener("toggle",e))}};function rd(r){let e=new Date(r*1e3),t=e.getHours(),n=e.getMinutes();return`${(t>9?"":"0")+t}:${(n>9?"":"0")+n}`}var Gi=class extends V{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.changeEditorButtons=this.$manyRefs.changeEditor,this.switchDialogContainer=this.$refs.switchDialog,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.setChangelogText=this.$opts.setChangelogText,this.autoSave={interval:null,frequency:3e4,last:0,pendingChange:!1},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this));let e=()=>this.autoSave.pendingChange=!0;window.$events.listen("editor-html-change",e),window.$events.listen("editor-markdown-change",e),this.titleElem.addEventListener("input",e);let t=Bt(this.updateChangelogDisplay.bind(this),300,!1);this.changelogInput.addEventListener("input",t),je(this.saveDraftButton,this.saveDraft.bind(this)),je(this.discardDraftButton,this.discardDraft.bind(this)),je(this.changeEditorButtons,this.changeEditor.bind(this))}setInitialFocus(){if(this.hasDefaultTitle)return this.titleElem.select();window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){this.autoSave.interval=window.setInterval(this.runAutoSave.bind(this),this.autoSave.frequency)}runAutoSave(){Date.now()-this.autoSave.last<this.autoSave.frequency/2||!this.autoSave.pendingChange||this.saveDraft()}savePage(){this.container.closest("form").submit()}async saveDraft(){let e={name:this.titleElem.value.trim()},t=this.getEditorComponent().getContent();Object.assign(e,t);let n=!1;try{let o=await window.$http.put(`/ajax/page/${this.pageId}/save-draft`,e);this.isNewDraft||this.toggleDiscardDraftVisibility(!0),this.draftNotifyChange(`${o.data.message} ${rd(o.data.timestamp)}`),this.autoSave.last=Date.now(),o.data.warning&&!this.shownWarningsCache.has(o.data.warning)&&(window.$events.emit("warning",o.data.warning),this.shownWarningsCache.add(o.data.warning)),n=!0,this.autoSave.pendingChange=!1}catch{try{let s=`draft-save-fail-${new Date().toISOString()}`;window.localStorage.setItem(s,JSON.stringify(e))}catch{}window.$events.emit("error",this.autosaveFailText)}return n}draftNotifyChange(e){this.draftDisplay.innerText=e,this.draftDisplayIcon.classList.add("visible"),window.setTimeout(()=>{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(){let e;try{e=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(t){return console.error(t)}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.toggleDiscardDraftVisibility(!1),window.$events.emit("editor::replace",{html:e.data.html,markdown:e.data.markdown}),this.titleElem.value=e.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),window.$events.emit("success",this.draftDiscardedText)}updateChangelogDisplay(){let e=this.changelogInput.value.trim();e.length===0?e=this.setChangelogText:e.length>16&&(e=e.slice(0,16)+"..."),this.changelogDisplay.innerText=e}toggleDiscardDraftVisibility(e){this.discardDraftWrap.classList.toggle("hidden",!e)}async changeEditor(e){e.preventDefault();let t=e.target.closest("a").href,n=window.$components.firstOnElement(this.switchDialogContainer,"confirm-dialog"),[o,s]=await Promise.all([this.saveDraft(),n.show()]);o&&s&&(window.location=t)}getEditorComponent(){return window.$components.first("markdown-editor")||window.$components.first("wysiwyg-editor")}};var Yi=class extends V{setup(){this.input=this.$refs.input,this.resetButton=this.$refs.resetButton,this.selectButton=this.$refs.selectButton,this.display=this.$refs.display,this.defaultDisplay=this.$refs.defaultDisplay,this.buttonSep=this.$refs.buttonSeperator,this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.resetButton.addEventListener("click",e=>{this.setValue("","")})}showPopup(){window.$components.first("entity-selector-popup").show(t=>{this.setValue(t.id,t.name)})}setValue(e,t){this.value=e,this.input.value=e,this.controlView(t)}controlView(e){let t=this.value&&this.value!==0;if(Wi(this.resetButton,t),Wi(this.buttonSep,t),Wi(this.defaultDisplay,!t),Wi(this.display,t),t){let n=this.getAssetIdFromVal();this.display.textContent=`#${n}, ${e}`,this.display.href=window.baseUrl(`/link/${n}`)}}getAssetIdFromVal(){return Number(this.value)}};function Wi(r,e){r.style.display=e?null:"none"}var Ki=class extends V{setup(){this.container=this.$el,this.cellSelector=this.$opts.cellSelector||"td,th",this.rowSelector=this.$opts.rowSelector||"tr";for(let e of this.$manyRefs.toggleAll||[])e.addEventListener("click",this.toggleAllClick.bind(this));for(let e of this.$manyRefs.toggleRow||[])e.addEventListener("click",this.toggleRowClick.bind(this));for(let e of this.$manyRefs.toggleColumn||[])e.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(e){e.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(e){e.preventDefault(),this.toggleAllInElement(e.target.closest(this.rowSelector))}toggleColumnClick(e){e.preventDefault();let t=e.target.closest(this.cellSelector),n=Array.from(t.parentElement.children).indexOf(t),o=this.container.querySelectorAll(this.rowSelector),s=[];for(let i of o){let a=i.children[n];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(e){let t=e.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(t)}toggleAllInputs(e){let t=e.length>0?e[0].checked:!1;for(let n of e)n.checked=!t,n.dispatchEvent(new Event("change"))}};var id=gn(nd());var Xi=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.showing=!1,this.isSelection=!1,this.pointerModeLink=!0,this.pointerSectionId="",this.setupListeners(),new id.default(this.container.querySelector("button"))}setupListeners(){We(this.container,"input","click",(t,n)=>{n.select(),t.stopPropagation()}),bn(this.container,["click","focus"],t=>{t.stopPropagation()}),We(this.container,"span.icon","click",(t,n)=>{t.stopPropagation(),this.pointerModeLink=!this.pointerModeLink,n.querySelector('[data-icon="include"]').style.display=this.pointerModeLink?"none":"inline",n.querySelector('[data-icon="link"]').style.display=this.pointerModeLink?"inline":"none",this.updateForTarget()}),bn(document.body,["click","focus"],t=>{!this.showing||this.isSelection||this.hidePointer()});let e=document.querySelector(".page-content");bn(e,["mouseup","keyup"],t=>{t.stopPropagation();let n=t.target.closest('[id^="bkmrk"]');n&&this.showPointerAtTarget(n,t.pageX)})}hidePointer(){this.container.style.display=null,this.showing=!1}showPointerAtTarget(e,t){if(window.getSelection().toString().length===0)return;this.pointerSectionId=e.id,this.updateForTarget(e),this.container.style.display="block";let o=e.getBoundingClientRect(),s=this.container.getBoundingClientRect(),a=Math.min(Math.max(t,o.left),o.right)-s.width/2,l=o.top-s.height-16;this.container.style.left=`${a}px`,this.container.style.top=`${l}px`,this.showing=!0,this.isSelection=!0,setTimeout(()=>{this.isSelection=!1},100);let c=()=>{this.hidePointer(),window.removeEventListener("scroll",c,{passive:!0})};window.addEventListener("scroll",c,{passive:!0})}updateForTarget(e){let t=this.pointerModeLink?window.baseUrl(`/link/${this.pageId}#${this.pointerSectionId}`):`{{@${this.pageId}#${this.pointerSectionId}}}`;this.pointerModeLink&&!t.startsWith("http")&&(t=window.location.protocol+"//"+window.location.host+t),this.container.querySelector("input").value=t;let n=this.container.querySelector("#pointer-edit");if(n&&e){let o=n.dataset.editHref,s=e.id,i=e.textContent&&e.textContent.substring(0,50);n.href=`${o}?content-id=${s}&content-text=${encodeURIComponent(i)}`}}};var Zi=class extends V{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let e=null;this.container.addEventListener("mousedown",t=>{e=t.target}),this.container.addEventListener("click",t=>{if(t.target===this.container&&e===this.container)return this.hide()}),je(this.hideButtons,t=>this.hide())}hide(e=null){Yn(this.container,120,e),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(e=null,t=null){Ta(this.container,120,e),this.onkeyup=n=>{n.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=t}};var Qi=class extends V{setup(){this.container=this.$el,this.mode=this.$opts.mode,this.lightContainer=this.$refs.lightContainer,this.darkContainer=this.$refs.darkContainer,this.container.addEventListener("tabs-change",t=>{let o=t.detail.showing==="color-scheme-panel-light"?"light":"dark";this.handleModeChange(o)});let e=t=>{this.updateAppColorsFromInputs(),t.target.name.startsWith("setting-app-color")&&this.updateLightForInput(t.target)};this.container.addEventListener("change",e),this.container.addEventListener("input",e)}handleModeChange(e){this.mode=e;let t=e==="dark";document.documentElement.classList.toggle("dark-mode",t),this.updateAppColorsFromInputs()}updateAppColorsFromInputs(){let t=(this.mode==="dark"?this.darkContainer:this.lightContainer).querySelectorAll('input[type="color"]');for(let n of t){let o=n.name.split("-"),s=o.indexOf("color"),i=o.slice(1,s).join("-");i==="app"&&(i="primary");let a="--color-"+i;document.body.style.setProperty(a,n.value)}}updateLightForInput(e){let t=e.name.replace("-color","-color-light"),n=e.value,o=this.hexToRgb(n),s="rgba("+[o.r,o.g,o.b,"0.15"].join(",")+")";console.log(e.name,t,n,s);let i=this.container.querySelector(`input[name="${t}"][type="hidden"]`);i.value=s}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return{r:t?parseInt(t[1],16):0,g:t?parseInt(t[2],16):0,b:t?parseInt(t[3],16):0}}};var Ji=class extends V{setup(){this.colorInput=this.$refs.input,this.resetButton=this.$refs.resetButton,this.defaultButton=this.$refs.defaultButton,this.currentColor=this.$opts.current,this.defaultColor=this.$opts.default,this.resetButton.addEventListener("click",()=>this.setValue(this.currentColor)),this.defaultButton.addEventListener("click",()=>this.setValue(this.defaultColor))}setValue(e){this.colorInput.value=e,this.colorInput.dispatchEvent(new Event("change",{bubbles:!0}))}};var eo=class extends V{setup(){this.typeControl=this.$refs.typeControl,this.pagePickerContainer=this.$refs.pagePickerContainer,this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}};var Fm={move_up(r,e,t){let n=r.parentNode,o=Array.from(n.children).indexOf(r),s=Math.max(o-1,0);n.insertBefore(r,n.children[s]||null)},move_down(r,e,t){let n=r.parentNode,o=Array.from(n.children).indexOf(r),s=Math.min(o+2,n.children.length);n.insertBefore(r,n.children[s]||null)},remove(r,e,t){t.appendChild(r)},add(r,e,t){e.appendChild(r)}},to=class extends V{setup(){this.elem=this.$el,this.input=this.$refs.input,this.shelfBookList=this.$refs.shelfBookList,this.allBookList=this.$refs.allBookList,this.bookSearchInput=this.$refs.bookSearch,this.sortButtonContainer=this.$refs.sortButtonContainer,this.lastSort=null,this.initSortable(),this.setupListeners()}initSortable(){let e=this.elem.querySelectorAll(".scroll-box");for(let t of e)new fr(t,{group:"shelf-books",ghostClass:"primary-background-light",handle:".handle",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){this.elem.addEventListener("click",e=>{let t=e.target.closest(".scroll-box-item button[data-action]");t&&this.sortItemActionClick(t)}),this.bookSearchInput.addEventListener("input",e=>{this.filterBooksByName(this.bookSearchInput.value)}),this.sortButtonContainer.addEventListener("click",e=>{let t=e.target.closest("button[data-sort]");t&&this.sortShelfBooks(t.dataset.sort)})}filterBooksByName(e){this.allBookList.style.height||(this.allBookList.style.height=this.allBookList.getBoundingClientRect().height+"px");let t=this.allBookList.children,n=e.trim().toLowerCase();for(let o of t){let s=!e||o.textContent.toLowerCase().includes(n);o.style.display=s?null:"none"}}sortItemActionClick(e){let t=e.closest(".scroll-box-item"),n=e.dataset.action,o=Fm[n];o(t,this.shelfBookList,this.allBookList),this.onChange()}onChange(){let e=Array.from(this.shelfBookList.querySelectorAll("[data-id]"));this.input.value=e.map(t=>t.getAttribute("data-id")).join(",")}sortShelfBooks(e){let t=Array.from(this.shelfBookList.children),n=e===this.lastSort;t.sort((o,s)=>{let i=o.dataset[e].toLowerCase(),a=s.dataset[e].toLowerCase();return n?i<a?i===a?0:1:-1:i<a?i===a?0:-1:1});for(let o of t)this.shelfBookList.append(o);this.lastSort=this.lastSort===e?null:e,this.onChange()}};function Rm(r){let e={};for(let[t,n]of Object.entries(r))e[n]=t;return e}var ro=class extends V{setup(){this.container=this.$el,this.mapById=JSON.parse(this.$opts.keyMap),this.mapByShortcut=Rm(this.mapById),this.hintsShowing=!1,this.hideHints=this.hideHints.bind(this),this.setupListeners()}setupListeners(){window.addEventListener("keydown",e=>{e.target.closest("input, select, textarea")||this.handleShortcutPress(e)}),window.addEventListener("keydown",e=>{e.key==="?"&&(this.hintsShowing?this.hideHints():this.showHints())})}handleShortcutPress(e){let n=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key].filter(s=>Boolean(s)).join(" + "),o=this.mapByShortcut[n];o&&this.runShortcut(o)&&e.preventDefault()}runShortcut(e){let t=this.container.querySelector(`[data-shortcut="${e}"]`);return t?t.matches("input, textarea, select")?(t.focus(),!0):t.matches("a, button")?(t.click(),!0):t.matches("div[tabindex]")?(t.click(),t.focus(),!0):(console.error("Shortcut attempted to be ran for element type that does not have handling setup",t),!1):!1}showHints(){let e=document.createElement("div");e.classList.add("shortcut-container"),this.container.append(e);let t=this.container.querySelectorAll("[data-shortcut]"),n=new Set;for(let o of t){let s=o.getAttribute("data-shortcut");if(n.has(s))continue;let i=this.mapById[s];this.showHintLabel(o,i,e),n.add(s)}window.addEventListener("scroll",this.hideHints),window.addEventListener("focus",this.hideHints),window.addEventListener("blur",this.hideHints),window.addEventListener("click",this.hideHints),this.hintsShowing=!0}showHintLabel(e,t,n){let o=e.getBoundingClientRect(),s=document.createElement("div");s.classList.add("shortcut-hint"),s.textContent=t;let i=document.createElement("div");i.classList.add("shortcut-linkage"),i.style.left=o.x+"px",i.style.top=o.y+"px",i.style.width=o.width+"px",i.style.height=o.height+"px",n.append(s,i);let a=s.getBoundingClientRect();s.style.insetInlineStart=`${o.x+o.width-(a.width+6)}px`,s.style.insetBlockStart=`${o.y+(o.height-a.height)/2}px`}hideHints(){this.container.querySelector(".shortcut-container").remove(),window.removeEventListener("scroll",this.hideHints),window.removeEventListener("focus",this.hideHints),window.removeEventListener("blur",this.hideHints),window.removeEventListener("click",this.hideHints),this.hintsShowing=!1}};var Om=["Control","Alt","Shift","Meta","Super"," ","+","Tab","Escape"],no=class extends V{setup(){this.input=this.$el,this.setupListeners()}setupListeners(){this.listenerRecordKey=this.listenerRecordKey.bind(this),this.input.addEventListener("focus",()=>{this.startListeningForInput()}),this.input.addEventListener("blur",()=>{this.stopListeningForInput()})}startListeningForInput(){this.input.addEventListener("keydown",this.listenerRecordKey)}listenerRecordKey(e){if(Om.includes(e.key))return;let t=[e.ctrlKey?"Ctrl":"",e.metaKey?"Cmd":"",e.key];this.input.value=t.filter(n=>Boolean(n)).join(" + ")}stopListeningForInput(){this.input.removeEventListener("keydown",this.listenerRecordKey)}};var io=class extends V{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let e=new fr(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:e.toArray()})},setData(t,n){let o=n.getAttribute("data-drag-content");if(o){let s=JSON.parse(o);for(let[i,a]of Object.entries(s))t.setData(i,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}};var oo=class extends V{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",e=>{if(this.filter&&!e.target.matches(this.filter))return;let t=this.$el.closest("form");t&&t.submit()})}};var so=class extends V{setup(){this.container=this.$el,this.tabs=Array.from(this.container.querySelectorAll('[role="tab"]')),this.panels=Array.from(this.container.querySelectorAll('[role="tabpanel"]')),this.container.addEventListener("click",e=>{let t=e.target.closest('[role="tab"]');t&&this.show(t.getAttribute("aria-controls"))})}show(e){for(let t of this.panels)t.toggleAttribute("hidden",t.id!==e);for(let t of this.tabs){let o=t.getAttribute("aria-controls")===e;t.setAttribute("aria-selected",o?"true":"false")}this.$emit("change",{showing:e})}};var ao=class extends V{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("input",e=>{let t=window.$components.firstOnElement(this.addRemoveComponentEl,"add-remove-rows");!this.hasEmptyRows()&&e.target.value&&t.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(n=>[...n.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}};var lo=class extends V{setup(){this.container=this.$el,this.list=this.$refs.list,this.searchInput=this.$refs.searchInput,this.searchButton=this.$refs.searchButton,this.searchCancel=this.$refs.searchCancel,this.setupListeners()}setupListeners(){We(this.container,"[template-action]","click",this.handleTemplateActionClick.bind(this)),We(this.container,".pagination a","click",this.handlePaginationClick.bind(this)),We(this.container,".template-item-content","click",this.handleTemplateItemClick.bind(this)),We(this.container,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.searchInput.addEventListener("keypress",e=>{e.key==="Enter"&&(e.preventDefault(),this.performSearch())}),this.searchButton.addEventListener("click",e=>this.performSearch()),this.searchCancel.addEventListener("click",e=>{this.searchInput.value="",this.performSearch()})}handleTemplateItemClick(e,t){let n=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(n,"replace")}handleTemplateItemDragStart(e,t){let n=t.closest("[template-id]").getAttribute("template-id");e.dataTransfer.setData("bookstack/template",n),e.dataTransfer.setData("text/plain",n)}handleTemplateActionClick(e,t){e.stopPropagation();let n=t.getAttribute("template-action"),o=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,n)}async insertTemplate(e,t="replace"){let n=await window.$http.get(`/templates/${e}`),o="editor::"+t;window.$events.emit(o,n.data)}async handlePaginationClick(e,t){e.preventDefault();let n=t.getAttribute("href"),o=await window.$http.get(n);this.list.innerHTML=o.data}async performSearch(){let e=this.searchInput.value,t=await window.$http.get("/templates",{search:e});this.searchCancel.style.display=e?"block":"none",this.list.innerHTML=t.data}};var co=class extends V{setup(){this.input=this.$el.querySelector("input[type=hidden]"),this.checkbox=this.$el.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let e=new Event("change");this.input.dispatchEvent(e)}};var uo=class extends V{setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.lastLayoutType="none",this.onDestroy=null,this.scrollCache={content:0,info:0},this.lastTabShown="content",this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",e=>{this.updateLayout()},{passive:!0})}updateLayout(){let e="tablet";window.innerWidth<=1e3&&(e="mobile"),window.innerWidth>=1400&&(e="desktop"),e!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),e==="desktop"?this.setupDesktop():e==="mobile"&&this.setupMobile(),this.lastLayoutType=e)}setupMobile(){for(let e of this.tabs)e.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let e of this.tabs)e.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(e){let t=e.target.dataset.tab;this.showTab(t)}showContent(){this.showTab("content",!1)}showTab(e,t=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let o of this.tabs){let s=o.dataset.tab===e;o.setAttribute("aria-selected",s?"true":"false")}let n=e==="info";if(this.container.classList.toggle("show-info",n),t){let s=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[e]||s,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[e]||s},50)}this.lastTabShown=e}};var ho=class extends V{setup(){this.container=this.$el,this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,We(this.container,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(e,t){e.preventDefault(),this.input.value=t.getAttribute("data-id"),this.userInfoContainer.innerHTML=t.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}hide(){window.$components.firstOnElement(this.container,"dropdown").hide()}};var fo=class extends V{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",e=>{e.target.checked&&e.target===this.allCheckbox?this.deselectIndividualEvents():e.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let e of this.checkboxes)e!==this.allCheckbox&&(e.checked=!1)}};function od(r){for(let e=1;e<5;e++)r.shortcuts.add("meta+"+e,"",["FormatBlock",!1,"h"+(e+1)]);r.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+o","","InsertOrderedList"),r.shortcuts.add("meta+p","","InsertUnorderedList"),r.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),r.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),r.shortcuts.add("meta+9","",function(){let e=r.selection.getNode(),t=e?e.closest(".callout"):null,n=["info","success","warning","danger"],s=(n.findIndex(a=>t&&t.classList.contains(a))+1)%n.length,i=n[s];r.formatter.apply("callout"+i)}),r.shortcuts.add("meta+shift+K","",function(){window.$components.first("entity-selector-popup").show(function(t){r.selection.isCollapsed()?r.insertContent(r.dom.createHTML("a",{href:t.link},r.dom.encode(t.name))):r.formatter.apply("link",{href:t.link}),r.selection.collapse(!1),r.focus()})})}function sd(r){window.$events.listen("editor::replace",({html:e})=>{r.setContent(e)}),window.$events.listen("editor::append",({html:e})=>{let t=r.getContent()+e;r.setContent(t)}),window.$events.listen("editor::prepend",({html:e})=>{let t=e+r.getContent();r.setContent(t)}),window.$events.listen("editor::insert",({html:e})=>{r.insertContent(e)}),window.$events.listen("editor::focus",()=>{r.initialized&&r.focus()})}function ad(r){let t=new URL(window.location).searchParams.get("content-id");t&&Pm(r,t)}function Pm(r,e){let t=r.dom.get(encodeURIComponent(e).replace(/!/g,"%21"));t&&(t.scrollIntoView(),r.selection.select(t,!0),r.selection.collapse(!1),r.focus())}var vr,po;function Mm(r){return r&&!!(r.textContent||r.innerText)}function ld(r,e,t){let n=new pn(t.clipboardData||t.dataTransfer);if(!n.hasItems()||n.containsTabularData())return;let o=n.getImages();for(let s of o){let i="image-"+Math.random().toString(16).slice(2),a=window.baseUrl("/loading.gif");t.preventDefault(),setTimeout(()=>{r.insertContent(`<p><img src="${a}" id="${i}"></p>`),$m(s,e.pageId).then(l=>{let c=l.name.replace(/"/g,""),u=`<img src="${l.thumbs.display}" alt="${c}" />`,d=r.dom.create("a",{target:"_blank",href:l.url},u);r.dom.replace(d,i)}).catch(l=>{r.dom.remove(i),window.$events.emit("error",e.translations.imageUploadErrorText),console.log(l)})},10)}}async function $m(r,e){if(r===null||r.type.indexOf("image")!==0)throw new Error("Not an image file");let t=r.name||`image-${Date.now()}.png`,n=new FormData;return n.append("file",r,t),n.append("uploaded_to",e),(await window.$http.post(window.baseUrl("/images/gallery"),n)).data}function _m(r,e){let t=r.selection.getNode();t.nodeName==="IMG"&&(vr=r.dom.getParent(t,".mceTemp"),!vr&&t.parentNode.nodeName==="A"&&!Mm(t.parentNode)&&(vr=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(po=t)}function Bm(r,e,t){let n=r.dom,o=tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX,t.clientY,r.getDoc()),s=t.dataTransfer&&t.dataTransfer.getData("bookstack/template");s&&(t.preventDefault(),window.$http.get(`/templates/${s}`).then(i=>{r.selection.setRng(o),r.undoManager.transact(function(){r.execCommand("mceInsertContent",!1,i.data.html)})})),n.getParent(o.startContainer,".mceTemp")?t.preventDefault():vr&&(t.preventDefault(),r.undoManager.transact(function(){r.selection.setRng(o),r.selection.setNode(vr),n.remove(vr)})),!t.isDefaultPrevented()&&po&&(t.preventDefault(),r.undoManager.transact(function(){let i=r.selection.getNode(),a=r.selection.getRng(),l=i.closest("body > *");a.startOffset>a.startContainer.length/2?l.after(po):l.before(po)})),t.isDefaultPrevented()||ld(r,e,t),vr=null}function cd(r,e){r.on("dragstart",()=>_m(r,e)),r.on("drop",t=>Bm(r,e,t)),r.on("paste",t=>ld(r,e,t))}function ud(r){return["undo redo","styles","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",r.textDirection==="rtl"?"ltr rtl":"","link table imagemanager-insert insertoverflow","code about fullscreen"].filter(n=>Boolean(n)).join(" | ")}function Nm(r){r.ui.registry.addGroupToolbarButton("formatoverflow",{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"}),r.ui.registry.addGroupToolbarButton("listoverflow",{icon:"more-drawer",tooltip:"More",items:"tasklist outdent indent"}),r.ui.registry.addGroupToolbarButton("insertoverflow",{icon:"more-drawer",tooltip:"More",items:"customhr codeeditor drawio media details"})}function Um(r){r.ui.registry.addContextToolbar("linkcontexttoolbar",{predicate(e){return e.closest("a")!==null},position:"node",scope:"node",items:"link unlink openlink"})}function zm(r){r.ui.registry.addContextToolbar("imagecontexttoolbar",{predicate(e){return e.closest("img")!==null},position:"node",scope:"node",items:"image"})}function dd(r,e){Nm(r),Um(r),zm(r)}var jm={"table-delete-column":'<svg width="24" height="24"><path d="M21 19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14c1.1 0 2 .9 2 2zm-2 0V5h-4v2.2h-2V5h-2v2.2H9V5H5v14h4v-2.1h2V19h2v-2.1h2V19Z"/><path d="M14.829 10.585 13.415 12l1.414 1.414c.943.943-.472 2.357-1.414 1.414L12 13.414l-1.414 1.414c-.944.944-2.358-.47-1.414-1.414L10.586 12l-1.414-1.415c-.943-.942.471-2.357 1.414-1.414L12 10.585l1.344-1.343c1.111-1.112 2.2.627 1.485 1.343z" style="fill-rule:nonzero"/></svg>',"table-delete-row":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14v-4h-2.2v-2H19v-2h-2.2V9H19V5H5v4h2.1v2H5v2h2.1v2H5Z"/><path d="M13.415 14.829 12 13.415l-1.414 1.414c-.943.943-2.357-.472-1.414-1.414L10.586 12l-1.414-1.414c-.944-.944.47-2.358 1.414-1.414L12 10.586l1.415-1.414c.942-.943 2.357.471 1.414 1.414L13.415 12l1.343 1.344c1.112 1.111-.627 2.2-1.343 1.485z" style="fill-rule:nonzero"/></svg>',"table-insert-column-after":'<svg width="24" height="24"><path d="M16 5h-5v14h5c1.235 0 1.234 2 0 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11c1.229 0 1.236 2 0 2zm-7 6V5H5v6zm0 8v-6H5v6zm11.076-6h-2v2c0 1.333-2 1.333-2 0v-2h-2c-1.335 0-1.335-2 0-2h2V9c0-1.333 2-1.333 2 0v2h1.9c1.572 0 1.113 2 .1 2z"/></svg>',"table-insert-column-before":'<svg width="24" height="24"><path d="M8 19h5V5H8C6.764 5 6.766 3 8 3h11a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8c-1.229 0-1.236-2 0-2zm7-6v6h4v-6zm0-8v6h4V5ZM3.924 11h2V9c0-1.333 2-1.333 2 0v2h2c1.335 0 1.335 2 0 2h-2v2c0 1.333-2 1.333-2 0v-2h-1.9c-1.572 0-1.113-2-.1-2z"/></svg>',"table-insert-row-above":'<svg width="24" height="24"><path d="M5 8v5h14V8c0-1.235 2-1.234 2 0v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8C3 6.77 5 6.764 5 8zm6 7H5v4h6zm8 0h-6v4h6zM13 3.924v2h2c1.333 0 1.333 2 0 2h-2v2c0 1.335-2 1.335-2 0v-2H9c-1.333 0-1.333-2 0-2h2v-1.9c0-1.572 2-1.113 2-.1z"/></svg>',"table-insert-row-after":'<svg width="24" height="24"><path d="M19 16v-5H5v5c0 1.235-2 1.234-2 0V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11c0 1.229-2 1.236-2 0zm-6-7h6V5h-6zM5 9h6V5H5Zm6 11.076v-2H9c-1.333 0-1.333-2 0-2h2v-2c0-1.335 2-1.335 2 0v2h2c1.333 0 1.333 2 0 2h-2v1.9c0 1.572-2 1.113-2 .1z"/></svg>',table:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2ZM5 14v5h6v-5zm14 0h-6v5h6zm0-7h-6v5h6zM5 12h6V7H5Z"/></svg>',"table-delete-table":'<svg width="24" height="24"><path d="M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14c0 1.1-.9 2-2 2zm0-2h14V5H5v14z"/><path d="m13.711 15.423-1.71-1.712-1.712 1.712c-1.14 1.14-2.852-.57-1.71-1.712l1.71-1.71-1.71-1.712c-1.143-1.142.568-2.853 1.71-1.71L12 10.288l1.711-1.71c1.141-1.142 2.852.57 1.712 1.71L13.71 12l1.626 1.626c1.345 1.345-.76 2.663-1.626 1.797z" style="fill-rule:nonzero;stroke-width:1.20992"/></svg>'};function hd(r){for(let[e,t]of Object.entries(jm))r.ui.registry.addIcon(e,t)}function fd(r){return r.tagName.toLowerCase()==="code-block"}function md(r,e,t,n){window.$components.first("code-editor").open(e,t,(o,s)=>{n(o,s),r.focus()})}function pd(r,e){md(r,e.getContent(),e.getLanguage(),(t,n)=>{e.setContent(t,n)})}function Hm(r){let e=r.getDoc(),t=e.defaultView;class n extends t.HTMLElement{constructor(){super(),this.attachShadow({mode:"open"});let s=document.querySelectorAll('link[rel="stylesheet"]:not([media="print"])'),i=Array.from(s).map(l=>l.cloneNode(!1)),a=document.createElement("div");a.style.pointerEvents="none",a.contentEditable="false",a.classList.add("CodeMirrorContainer"),this.shadowRoot.append(...i,a)}getLanguage(){let s=l=>(l.split(" ").filter(u=>u.startsWith("language-"))[0]||"").replace("language-",""),i=this.querySelector("code"),a=this.querySelector("pre");return s(a.className)||i&&s(i.className)||""}setContent(s,i){this.cm&&importVersioned("code").then(c=>{c.setContent(this.cm,s),c.setMode(this.cm,i,s)});let a=this.querySelector("pre");a||(a=e.createElement("pre"),this.append(a)),a.innerHTML="";let l=e.createElement("code");a.append(l),l.innerText=s,l.className=`language-${i}`}getContent(){let s=this.querySelector("code")||this.querySelector("pre"),i=document.createElement("pre");i.innerHTML=s.innerHTML.replace(/\ufeff/g,"");let a=i.querySelectorAll("br");for(let l of a)l.replaceWith(`
+`);return i.textContent}connectedCallback(){let s=Date.now();if(this.cm)return;this.cleanChildContent();let i=this.getContent(),l=i.split(`
+`).length*19.2+18+24;this.style.height=`${l}px`;let c=this.shadowRoot.querySelector(".CodeMirrorContainer"),u=d=>{this.cm=d.wysiwygView(c,i,this.getLanguage()),setTimeout(()=>d.updateLayout(this.cm),10),setTimeout(()=>this.style.height=null,12)};window.importVersioned("code").then(d=>{let h=Date.now()-s<20?20:0;setTimeout(()=>u(d),h)})}cleanChildContent(){let s=this.querySelector("pre");if(s)for(let i of s.childNodes)i.nodeName==="#text"&&i.textContent==="\uFEFF"&&i.remove()}}t.customElements.define("code-block",n)}function Vm(r,e){r.ui.registry.addIcon("codeblock",'<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5Z"/><path d="M11.103 15.423c.277.277.277.738 0 .922a.692.692 0 0 1-1.106 0l-4.057-3.78a.738.738 0 0 1 0-1.107l4.057-3.872c.276-.277.83-.277 1.106 0a.724.724 0 0 1 0 1.014L7.6 12.012ZM12.897 8.577c-.245-.312-.2-.675.08-.955.28-.281.727-.27 1.027.033l4.057 3.78a.738.738 0 0 1 0 1.107l-4.057 3.872c-.277.277-.83.277-1.107 0a.724.724 0 0 1 0-1.014l3.504-3.412z"/></svg>'),r.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){r.execCommand("codeeditor")}}),r.ui.registry.addButton("editcodeeditor",{tooltip:"Edit code block",icon:"edit-block",onAction(){r.execCommand("codeeditor")}}),r.addCommand("codeeditor",()=>{let t=r.selection.getNode(),n=t.ownerDocument;if(fd(t))pd(r,t);else{let o=r.selection.getContent({format:"text"});md(r,o,"",(s,i)=>{let a=n.createElement("pre"),l=n.createElement("code");l.classList.add(`language-${i}`),l.innerText=s,a.append(l),r.insertContent(a.outerHTML)})}}),r.on("dblclick",t=>{let n=r.selection.getNode();fd(n)&&pd(r,n)}),r.on("PreInit",()=>{r.parser.addNodeFilter("pre",function(t){for(let n of t){let o=tinymce.html.Node.create("code-block",{contenteditable:"false"}),s=n.getAll("span");for(let i of s)i.unwrap();n.attr("style",null),n.wrap(o)}}),r.parser.addNodeFilter("code-block",function(t){for(let n of t)n.attr("contenteditable","false")}),r.serializer.addNodeFilter("code-block",function(t){for(let n of t)n.unwrap()})}),r.ui.registry.addContextToolbar("codeeditor",{predicate:function(t){return t.nodeName.toLowerCase()==="code-block"},items:"editcodeeditor",position:"node",scope:"node"}),r.on("PreInit",()=>{Hm(r)})}function gd(r){return Vm}var Ct=null,br=null,yr={};function Ns(r){return r.hasAttribute("drawio-diagram")}function qm(r,e=null){Ct=r,br=e,window.$components.first("image-manager").show(function(n){if(e){let o=e.querySelector("img");Ct.undoManager.transact(function(){Ct.dom.setAttrib(o,"src",n.url),Ct.dom.setAttrib(e,"drawio-diagram",n.id)})}else{let o=`<div drawio-diagram="${n.id}" contenteditable="false"><img src="${n.url}"></div>`;Ct.insertContent(o)}},"drawio")}function vd(r,e=null){Ct=r,br=e,kt.show(yr.drawioUrl,Wm,Gm)}async function Gm(r){let e="image-"+Math.random().toString(16).slice(2),t=window.baseUrl("/loading.gif"),n=o=>{o.status===413?window.$events.emit("error",yr.translations.serverUploadLimitText):window.$events.emit("error",yr.translations.imageUploadErrorText),console.log(o)};if(br){kt.close();let o=br.querySelector("img");try{let s=await kt.upload(r,yr.pageId);Ct.undoManager.transact(function(){Ct.dom.setAttrib(o,"src",s.url),Ct.dom.setAttrib(br,"drawio-diagram",s.id)})}catch(s){n(s)}return}setTimeout(async()=>{Ct.insertContent(`<div drawio-diagram contenteditable="false"><img src="${t}" id="${e}"></div>`),kt.close();try{let o=await kt.upload(r,yr.pageId);Ct.undoManager.transact(function(){Ct.dom.setAttrib(e,"src",o.url),Ct.dom.get(e).parentNode.setAttribute("drawio-diagram",o.id)})}catch(o){Ct.dom.remove(e),n(o)}},5)}function Wm(){if(!br)return Promise.resolve("");let r=br.getAttribute("drawio-diagram");return kt.load(r)}function yd(r){return yr=r,function(e,t){e.addCommand("drawio",()=>{let n=e.selection.getNode();vd(e,Ns(n)?n:null)}),e.ui.registry.addIcon("diagram",`<svg width="24" height="24" fill="${yr.darkMode?"#BBB":"#000000"}" xmlns="http://www.w3.org/2000/svg"><path d="M20.716 7.639V2.845h-4.794v1.598h-7.99V2.845H3.138v4.794h1.598v7.99H3.138v4.794h4.794v-1.598h7.99v1.598h4.794v-4.794h-1.598v-7.99zM4.736 4.443h1.598V6.04H4.736zm1.598 14.382H4.736v-1.598h1.598zm9.588-1.598h-7.99v-1.598H6.334v-7.99h1.598V6.04h7.99v1.598h1.598v7.99h-1.598zm3.196 1.598H17.52v-1.598h1.598zM17.52 6.04V4.443h1.598V6.04zm-4.21 7.19h-2.79l-.582 1.599H8.643l2.717-7.191h1.119l2.724 7.19h-1.302zm-2.43-1.006h2.086l-1.039-3.06z"/></svg>`),e.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){e.execCommand("drawio"),window.document.body.dispatchEvent(new Event("mousedown",{bubbles:!0}))},fetch(n){n([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(n,o){if(o==="drawing-manager"){let s=e.selection.getNode();qm(e,Ns(s)?s:null)}}}),e.on("dblclick",n=>{let o=e.selection.getNode();Ns(o)&&vd(e,o)}),e.on("SetContent",function(){let n=e.dom.select("body > div[drawio-diagram]");n.length&&e.undoManager.transact(function(){for(let o of n)o.setAttribute("contenteditable","false")})})}}function Ym(r,e){r.addCommand("InsertHorizontalRule",function(){let t=document.createElement("hr"),n=r.selection.getNode();n.parentNode.insertBefore(t,n)}),r.ui.registry.addButton("customhr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){r.execCommand("InsertHorizontalRule")}})}function bd(r){return Ym}function Km(r,e){r.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.$components.first("image-manager").show(function(n){let o=n.thumbs.display||n.url,s=`<a href="${n.url}" target="_blank">`;s+=`<img src="${o}" alt="${n.name}">`,s+="</a>",r.execCommand("mceInsertContent",!1,s)},"gallery")}})}function xd(r){return Km}function Xm(r,e){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/wysiwyg")};r.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){tinymce.activeEditor.windowManager.openUrl(t)}})}function wd(r){return Xm}var Cd=["p","h1","h2","h3","h4","h5","h6","div","blockquote","pre","code-block","details","ul","ol","table"];function Zm(r,e){r.ui.registry.addIcon("details",'<svg width="24" height="24"><path d="M8.2 9a.5.5 0 0 0-.4.8l4 5.6a.5.5 0 0 0 .8 0l4-5.6a.5.5 0 0 0-.4-.8ZM20.122 18.151h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7zM20.122 3.042h-16c-.964 0-.934 2.7 0 2.7h16c1.139 0 1.173-2.7 0-2.7z"/></svg>'),r.ui.registry.addIcon("togglefold",'<svg height="24" width="24"><path d="M8.12 19.3c.39.39 1.02.39 1.41 0L12 16.83l2.47 2.47c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.02-.39-1.41 0l-3.17 3.17c-.4.38-.4 1.02-.01 1.41zm7.76-14.6c-.39-.39-1.02-.39-1.41 0L12 7.17 9.53 4.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.03 0 1.42l3.17 3.17c.39.39 1.02.39 1.41 0l3.17-3.17c.4-.39.4-1.03.01-1.42z"/></svg>'),r.ui.registry.addIcon("togglelabel",'<svg height="18" width="18" viewBox="0 0 24 24"><path d="M21.41,11.41l-8.83-8.83C12.21,2.21,11.7,2,11.17,2H4C2.9,2,2,2.9,2,4v7.17c0,0.53,0.21,1.04,0.59,1.41l8.83,8.83 c0.78,0.78,2.05,0.78,2.83,0l7.17-7.17C22.2,13.46,22.2,12.2,21.41,11.41z M6.5,8C5.67,8,5,7.33,5,6.5S5.67,5,6.5,5S8,5.67,8,6.5 S7.33,8,6.5,8z"/></svg>'),r.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){r.execCommand("InsertDetailsBlock")}}),r.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){tg(r)}}),r.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Ed(r)}}),r.on("dblclick",t=>{!mo(r)||t.target.closest("doc-root")||Ed(r)}),r.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){mo(r).toggleAttribute("open"),r.focus()}}),r.addCommand("InsertDetailsBlock",function(){let t=r.selection.getContent({format:"html"}),n=document.createElement("details"),o=document.createElement("summary"),s="details-"+Date.now();n.setAttribute("data-id",s),n.appendChild(o),t||(t="<p><br></p>"),n.innerHTML+=t,r.insertContent(n.outerHTML),r.focus();let i=r.dom.select(`[data-id="${s}"]`)[0]||null;if(i){let a=i.querySelector("doc-root > *");a&&a.focus(),i.removeAttribute("data-id")}}),r.ui.registry.addContextToolbar("details",{predicate:function(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),r.on("PreInit",()=>{rg(r)})}function Ed(r){let e=mo(r);r.windowManager.open(Jm(r)).setData({summary:Qm(e)})}function mo(r){return r.selection.getNode().closest("details")}function Qm(r){let e=r.querySelector("summary");return e?e.textContent:""}function Jm(r){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(e){let{summary:t}=e.getData();eg(r,t),e.close()}}}function eg(r,e){let t=mo(r);t&&r.undoManager.transact(()=>{let n=t.querySelector("summary");n||(n=document.createElement("summary"),t.prepend(n)),n.textContent=e})}function tg(r){let e=r.selection.getNode().closest("details"),t=r.selection.getBookmark();if(e){let n=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");r.undoManager.transact(()=>{for(let o of n)e.parentNode.insertBefore(o,e);e.remove()})}r.focus(),r.selection.moveToBookmark(t)}function rg(r){r.parser.addNodeFilter("details",function(e){for(let t of e)ng(t)}),r.serializer.addNodeFilter("details",function(e){for(let t of e)Us(t),t.attr("open",null)}),r.serializer.addNodeFilter("doc-root",function(e){for(let t of e)t.unwrap()})}function ng(r){Us(r),r.attr("contenteditable","false");let e=tinymce.html.Node.create("doc-root",{contenteditable:"true"}),t=null;for(let n of r.children()){if(n.name==="summary")continue;Cd.includes(n.name)?(e.append(n),t=null):(t||(t=tinymce.html.Node.create("p"),e.append(t)),t.append(n))}r.append(e)}function Us(r){r.attr("contenteditable",null);let e=!1;for(let t of r.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&Us(r)}function Sd(r){return Zm}function ig(r,e){r.ui.registry.addIcon("tasklist",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M22,8c0-0.55-0.45-1-1-1h-7c-0.55,0-1,0.45-1,1s0.45,1,1,1h7C21.55,9,22,8.55,22,8z M13,16c0,0.55,0.45,1,1,1h7 c0.55,0,1-0.45,1-1c0-0.55-0.45-1-1-1h-7C13.45,15,13,15.45,13,16z M10.47,4.63c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25 c-0.39,0.39-1.02,0.39-1.42,0L2.7,8.16c-0.39-0.39-0.39-1.02,0-1.41c0.39-0.39,1.02-0.39,1.41,0l1.42,1.42l3.54-3.54 C9.45,4.25,10.09,4.25,10.47,4.63z M10.48,12.64c0.39,0.39,0.39,1.02,0,1.41l-4.23,4.25c-0.39,0.39-1.02,0.39-1.42,0L2.7,16.16 c-0.39-0.39-0.39-1.02,0-1.41s1.02-0.39,1.41,0l1.42,1.42l3.54-3.54C9.45,12.25,10.09,12.25,10.48,12.64L10.48,12.64z"/></svg>'),r.ui.registry.addToggleButton("tasklist",{tooltip:"Task list",icon:"tasklist",active:!1,onAction(o){o.isActive()?r.execCommand("RemoveList"):r.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:"task-list-item"},"list-style-type":"tasklist"})},onSetup(o){r.on("NodeChange",s=>{let i=s.parents.find(l=>l.nodeName==="LI"),a=i&&i.classList.contains("task-list-item");o.setActive(Boolean(a))})}});let t=r.ui.registry.getAll().buttons.bullist;t.onSetup=function(o){r.on("NodeChange",s=>{let i=s.parents.find(c=>c.nodeName==="LI"),a=i&&i.classList.contains("task-list-item"),l=i&&i.parentNode.nodeName==="UL";o.setActive(Boolean(l&&!a))})},t.onAction=function(){og(r.selection.getNode())&&r.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}}),r.execCommand("InsertUnorderedList",null,{"list-item-attributes":{class:null}})};let n=r.ui.registry.getAll().buttons.numlist;n.onAction=function(){r.execCommand("InsertOrderedList",null,{"list-item-attributes":{class:null}})},r.on("PreInit",()=>{r.parser.addNodeFilter("li",function(o){for(let s of o)s.attributes.map.class==="task-list-item"&&ag(s)}),r.serializer.addNodeFilter("li",function(o){for(let s of o)s.attributes.map.class==="task-list-item"&&lg(s)})}),r.on("click",function(o){let s=o.target;s.nodeName==="LI"&&s.classList.contains("task-list-item")&&(sg(o,s,r),o.preventDefault())})}function og(r){let e=r.closest("li");return e&&e.parentNode.nodeName==="UL"&&e.classList.contains("task-list-item")}function sg(r,e,t){let n=e.getBoundingClientRect();r.clientX<=n.right&&r.clientX>=n.left&&r.clientY>=n.top&&r.clientY<=n.bottom||t.undoManager.transact(()=>{e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","checked")})}function ag(r){r.attr("class","task-list-item");for(let e of r.children())e.name==="input"&&(e.attr("checked")==="checked"&&r.attr("checked","checked"),e.remove())}function lg(r){let e=r.attr("checked")==="checked";r.attr("checked",null);let t={type:"checkbox",disabled:"disabled"};e&&(t.checked="checked");let n=tinymce.html.Node.create("input",t);n.shortEnded=!0,r.firstChild?r.insert(n,r.firstChild,!0):r.append(n)}function Ad(r){return ig}var cg=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],ug={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}},dg=["#BFEDD2","","#FBEEB8","","#F8CAC6","","#ECCAFA","","#C2E0F4","","#2DC26B","","#F1C40F","","#E03E2D","","#B96AD9","","#3598DB","","#169179","","#E67E23","","#BA372A","","#843FA1","","#236FA1","","#ECF0F1","","#CED4D9","","#95A5A6","","#7E8C8D","","#34495E","","#000000","","#ffffff",""];function hg(r,e,t){t.filetype==="file"&&window.$components.first("entity-selector-popup").show(o=>{r(o.link,{text:o.name,title:o.name})}),t.filetype==="image"&&window.$components.first("image-manager").show(function(o){r(o.url,{alt:o.name})},"gallery")}function fg(r){let e=["image","table","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details","tasklist",r.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",gd(r)),window.tinymce.PluginManager.add("customhr",bd(r)),window.tinymce.PluginManager.add("imagemanager",xd(r)),window.tinymce.PluginManager.add("about",wd(r)),window.tinymce.PluginManager.add("details",Sd(r)),window.tinymce.PluginManager.add("tasklist",Ad(r)),r.drawioUrl&&(window.tinymce.PluginManager.add("drawio",yd(r)),e.push("drawio")),e.filter(t=>Boolean(t))}function pg(){let r=document.head.innerHTML.split(`