-`,i.map=[t,e.line],!0}});var Ll=re((Wv,Dl)=>{"use strict";Dl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h=!1,d=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||d+3>p||(s=e.src.charCodeAt(d),s!==126&&s!==96)||(u=d,d=e.skipChars(d,s),i=d-u,i<3)||(f=e.src.slice(u,d),a=e.src.slice(d,p),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(o)return!0;for(l=t;l++,!(l>=n||(d=u=e.bMarks[l]+e.tShift[l],p=e.eMarks[l],d<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(d)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(d=e.skipChars(d,s),!(d-u<i)&&(d=e.skipSpaces(d),!(d<p)))){h=!0;break}return i=e.sCount[t],e.line=l+(h?1:0),c=e.push("fence","code",0),c.info=a,c.content=e.getLines(t+1,l,i,!0),c.markup=f,c.map=[t,e.line],!0}});var Ol=re((Yv,Rl)=>{"use strict";var Fl=_e().isSpace;Rl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M,A,O,k,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=d=e.sCount[t]+1,e.src.charCodeAt(I)===32?(I++,l++,d++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[t]+d)%4===3?(I++,l++,d++,s=!1):s=!0):S=!1,p=[e.bMarks[t]],e.bMarks[t]=I;I<P&&(i=e.src.charCodeAt(I),Fl(i));){i===9?d+=4-(d+e.bsCount[t]+(s?1:0))%4:d++;I++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(S?1:0),c=I>=P,x=[e.sCount[t]],e.sCount[t]=d-l,C=[e.tShift[t]],e.tShift[t]=I-e.bMarks[t],A=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",h=t+1;h<n&&(k=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&&!k){for(l=d=e.sCount[h]+1,e.src.charCodeAt(I)===32?(I++,l++,d++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[h]+d)%4===3?(I++,l++,d++,s=!1):s=!0):S=!1,p.push(e.bMarks[h]),e.bMarks[h]=I;I<P&&(i=e.src.charCodeAt(I),Fl(i));){i===9?d+=4-(d+e.bsCount[h]+(s?1:0))%4:d++;I++}c=I>=P,m.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(S?1:0),x.push(e.sCount[h]),e.sCount[h]=d-l,C.push(e.tShift[h]),e.tShift[h]=I-e.bMarks[h];continue}if(c)break;for(M=!1,a=0,u=A.length;a<u;a++)if(A[a](e,h,n,!0)){M=!0;break}if(M){e.lineMax=h,e.blkIndent!==0&&(p.push(e.bMarks[h]),m.push(e.bsCount[h]),C.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}p.push(e.bMarks[h]),m.push(e.bsCount[h]),C.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]=-1}for(v=e.blkIndent,e.blkIndent=0,O=e.push("blockquote_open","blockquote",1),O.markup=">",O.map=f=[t,0],e.md.block.tokenize(e,t,h),O=e.push("blockquote_close","blockquote",-1),O.markup=">",e.lineMax=D,e.parentType=b,f[1]=e.line,a=0;a<C.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=C[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=m[a];return e.blkIndent=v,!0}});var Ml=re((Kv,Pl)=>{"use strict";var wh=_e().isSpace;Pl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u++),s!==42&&s!==45&&s!==95))return!1;for(i=1;u<c;){if(a=e.src.charCodeAt(u++),a!==s&&!wh(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 Ul=re((Xv,$l)=>{"use strict";var Bl=_e().isSpace;function _l(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),!Bl(s))?-1:n}function Nl(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),!Bl(t))?-1:o}function Eh(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)}$l.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M,A,O,k,D,I,P,N,B,H,Z,W,te=!1,ne=!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&&(te=!0),(P=Nl(e,t))>=0){if(f=!0,B=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(B,P-1)),te&&b!==1)return!1}else if((P=_l(e,t))>=0)f=!1;else return!1;if(te&&e.skipSpaces(P)>=e.eMarks[t])return!1;if(v=e.src.charCodeAt(P-1),o)return!0;for(m=e.tokens.length,f?(W=e.push("ordered_list_open","ol",1),b!==1&&(W.attrs=[["start",b]])):W=e.push("bullet_list_open","ul",1),W.map=p=[t,0],W.markup=String.fromCharCode(v),C=t,N=!1,Z=e.md.block.ruler.getRules("list"),A=e.parentType,e.parentType="list";C<n;){for(I=P,x=e.eMarks[C],c=S=e.sCount[C]+P-(e.bMarks[t]+e.tShift[t]);I<x;){if(s=e.src.charCodeAt(I),s===9)S+=4-(S+e.bsCount[C])%4;else if(s===32)S++;else break;I++}if(i=I,i>=x?u=1:u=S-c,u>4&&(u=1),l=c+u,W=e.push("list_item_open","li",1),W.markup=String.fromCharCode(v),W.map=h=[t,0],f&&(W.info=e.src.slice(B,P-1)),D=e.tight,k=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]=S,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||N)&&(ne=!1),N=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=M,e.tShift[t]=k,e.sCount[t]=O,e.tight=D,W=e.push("list_item_close","li",-1),W.markup=String.fromCharCode(v),C=t=e.line,h[1]=C,i=e.bMarks[t],C>=n||e.sCount[C]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(H=!1,a=0,d=Z.length;a<d;a++)if(Z[a](e,C,n,!0)){H=!0;break}if(H)break;if(f){if(P=Nl(e,C),P<0)break;B=e.bMarks[C]+e.tShift[C]}else if(P=_l(e,C),P<0)break;if(v!==e.src.charCodeAt(P-1))break}return f?W=e.push("ordered_list_close","ol",-1):W=e.push("bullet_list_close","ul",-1),W.markup=String.fromCharCode(v),p[1]=C,e.line=C,e.parentType=A,ne&&Eh(e,m),!0}});var jl=re((Zv,zl)=>{"use strict";var Sh=_e().normalizeReference,Tn=_e().isSpace;zl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M=0,A=e.bMarks[t]+e.tShift[t],O=e.eMarks[t],k=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(A)!==91)return!1;for(;++A<O;)if(e.src.charCodeAt(A)===93&&e.src.charCodeAt(A-1)!==92){if(A+1===O||e.src.charCodeAt(A+1)!==58)return!1;break}for(l=e.lineMax,C=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";k<l&&!e.isEmpty(k);k++)if(!(e.sCount[k]-e.blkIndent>3)&&!(e.sCount[k]<0)){for(x=!1,c=0,f=C.length;c<f;c++)if(C[c](e,k,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,k,e.blkIndent,!1).trim(),O=b.length,A=1;A<O;A++){if(s=b.charCodeAt(A),s===91)return!1;if(s===93){d=A;break}else s===10?M++:s===92&&(A++,A<O&&b.charCodeAt(A)===10&&M++)}if(d<0||b.charCodeAt(d+1)!==58)return!1;for(A=d+2;A<O;A++)if(s=b.charCodeAt(A),s===10)M++;else if(!Tn(s))break;if(m=e.md.helpers.parseLinkDestination(b,A,O),!m.ok||(u=e.md.normalizeLink(m.str),!e.md.validateLink(u)))return!1;for(A=m.pos,M+=m.lines,i=A,a=M,v=A;A<O;A++)if(s=b.charCodeAt(A),s===10)M++;else if(!Tn(s))break;for(m=e.md.helpers.parseLinkTitle(b,A,O),A<O&&v!==A&&m.ok?(S=m.str,A=m.pos,M+=m.lines):(S="",A=i,M=a);A<O&&(s=b.charCodeAt(A),!!Tn(s));)A++;if(A<O&&b.charCodeAt(A)!==10&&S)for(S="",A=i,M=a;A<O&&(s=b.charCodeAt(A),!!Tn(s));)A++;return A<O&&b.charCodeAt(A)!==10||(h=Sh(b.slice(1,d)),!h)?!1:(o||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[h]>"u"&&(e.env.references[h]={title:S,href:u}),e.parentType=p,e.line=t+M+1),!0)}});var ql=re((Qv,Hl)=>{"use strict";Hl.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 Gi=re((Jv,Vi)=>{"use strict";var Ch="[a-zA-Z_:][a-zA-Z0-9:._-]*",Ah="[^\"'=<>`\\x00-\\x20]+",kh="'[^']*'",Th='"[^"]*"',Ih="(?:"+Ah+"|"+kh+"|"+Th+")",Dh="(?:\\s+"+Ch+"(?:\\s*=\\s*"+Ih+")?)",Vl="<[A-Za-z][A-Za-z0-9\\-]*"+Dh+"*\\s*\\/?>",Gl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Lh="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Fh="<[?][\\s\\S]*?[?]>",Rh="<![A-Z]+\\s+[^>]*>",Oh="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Ph=new RegExp("^(?:"+Vl+"|"+Gl+"|"+Lh+"|"+Fh+"|"+Rh+"|"+Oh+")"),Mh=new RegExp("^(?:"+Vl+"|"+Gl+")");Vi.exports.HTML_TAG_RE=Ph;Vi.exports.HTML_OPEN_CLOSE_TAG_RE=Mh});var Yl=re((ey,Wl)=>{"use strict";var _h=ql(),Nh=Gi().HTML_OPEN_CLOSE_TAG_RE,br=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+_h.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Nh.source+"\\s*$"),/^$/,!1]];Wl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(u)!==60)return!1;for(l=e.src.slice(u,c),s=0;s<br.length&&!br[s][0].test(l);s++);if(s===br.length)return!1;if(o)return br[s][2];if(i=t+1,!br[s][1].test(l)){for(;i<n&&!(e.sCount[i]<e.blkIndent);i++)if(u=e.bMarks[i]+e.tShift[i],c=e.eMarks[i],l=e.src.slice(u,c),br[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 Zl=re((ty,Xl)=>{"use strict";var Kl=_e().isSpace;Xl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u),s!==35||u>=c))return!1;for(i=1,s=e.src.charCodeAt(++u);s===35&&u<c&&i<=6;)i++,s=e.src.charCodeAt(++u);return i>6||u<c&&!Kl(s)?!1:(o||(c=e.skipSpacesBack(c,u),a=e.skipCharsBack(c,35,u),a>u&&Kl(e.src.charCodeAt(a-1))&&(c=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(u,c).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(i),-1),l.markup="########".slice(0,i)),!0)}});var Jl=re((ry,Ql)=>{"use strict";Ql.exports=function(e,t,n){var o,s,i,a,l,u,c,f,h,d=t+1,p,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";d<n&&!e.isEmpty(d);d++)if(!(e.sCount[d]-e.blkIndent>3)){if(e.sCount[d]>=e.blkIndent&&(u=e.bMarks[d]+e.tShift[d],c=e.eMarks[d],u<c&&(h=e.src.charCodeAt(u),(h===45||h===61)&&(u=e.skipChars(u,h),u=e.skipSpaces(u),u>=c)))){f=h===61?1:2;break}if(!(e.sCount[d]<0)){for(s=!1,i=0,a=m.length;i<a;i++)if(m[i](e,d,n,!0)){s=!0;break}if(s)break}}return f?(o=e.getLines(t,d,e.blkIndent,!1).trim(),e.line=d+1,l=e.push("heading_open","h"+String(f),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(f),-1),l.markup=String.fromCharCode(h),e.parentType=p,!0):!1}});var tu=re((ny,eu)=>{"use strict";eu.exports=function(e,t){var n,o,s,i,a,l,u=t+1,c=e.md.block.ruler.getRules("paragraph"),f=e.lineMax;for(l=e.parentType,e.parentType="paragraph";u<f&&!e.isEmpty(u);u++)if(!(e.sCount[u]-e.blkIndent>3)&&!(e.sCount[u]<0)){for(o=!1,s=0,i=c.length;s<i;s++)if(c[s](e,u,f,!0)){o=!0;break}if(o)break}return n=e.getLines(t,u,e.blkIndent,!1).trim(),e.line=u,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 iu=re((iy,nu)=>{"use strict";var ru=kn(),In=_e().isSpace;function Pt(r,e,t,n){var o,s,i,a,l,u,c,f;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,f=!1,i=a=u=c=0,l=s.length;a<l;a++){if(o=s.charCodeAt(a),!f)if(In(o)){u++,o===9?c+=4-c%4:c++;continue}else f=!0;(o===10||a===l-1)&&(o!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(u),this.sCount.push(c),this.bsCount.push(0),f=!1,u=0,c=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}Pt.prototype.push=function(r,e,t){var n=new ru(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};Pt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Pt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Pt.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!In(t));e++);return e};Pt.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!In(this.src.charCodeAt(--e)))return e+1;return e};Pt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};Pt.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};Pt.prototype.getLines=function(e,t,n,o){var s,i,a,l,u,c,f,h=e;if(e>=t)return"";for(c=new Array(t-e),s=0;h<t;h++,s++){for(i=0,f=l=this.bMarks[h],h+1<t||o?u=this.eMarks[h]+1:u=this.eMarks[h];l<u&&i<n;){if(a=this.src.charCodeAt(l),In(a))a===9?i+=4-(i+this.bsCount[h])%4:i++;else if(l-f<this.tShift[h])i++;else break;l++}i>n?c[s]=new Array(i-n+1).join(" ")+this.src.slice(l,u):c[s]=this.src.slice(l,u)}return c.join("")};Pt.prototype.Token=ru;nu.exports=Pt});var su=re((oy,ou)=>{"use strict";var Bh=Cn(),Dn=[["table",kl(),["paragraph","reference"]],["code",Il()],["fence",Ll(),["paragraph","reference","blockquote","list"]],["blockquote",Ol(),["paragraph","reference","blockquote","list"]],["hr",Ml(),["paragraph","reference","blockquote","list"]],["list",Ul(),["paragraph","reference","blockquote"]],["reference",jl()],["html_block",Yl(),["paragraph","reference","blockquote"]],["heading",Zl(),["paragraph","reference","blockquote"]],["lheading",Jl()],["paragraph",tu()]];function Ln(){this.ruler=new Bh;for(var r=0;r<Dn.length;r++)this.ruler.push(Dn[r][0],Dn[r][1],{alt:(Dn[r][2]||[]).slice()})}Ln.prototype.tokenize=function(r,e,t){for(var n,o,s=this.ruler.getRules(""),i=s.length,a=e,l=!1,u=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=u){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)}};Ln.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))};Ln.prototype.State=iu();ou.exports=Ln});var lu=re((sy,au)=>{"use strict";function $h(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}}au.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!$h(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var cu=re((ay,uu)=>{"use strict";var Uh=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;uu.exports=function(e,t){var n,o,s,i,a,l,u,c;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(Uh),!s)||(i=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-i.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),u=e.md.normalizeLink(l),!e.md.validateLink(u))?!1:(t||(e.pending=e.pending.slice(0,-i.length),c=e.push("link_open","a",1),c.attrs=[["href",u]],c.markup="linkify",c.info="auto",c=e.push("text","",0),c.content=e.md.normalizeLinkText(l),c=e.push("link_close","a",-1),c.markup="linkify",c.info="auto"),e.pos+=l.length-i.length,!0)}});var fu=re((ly,du)=>{"use strict";var zh=_e().isSpace;du.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&&zh(e.src.charCodeAt(i));)i++;return e.pos=i,!0}});var pu=re((uy,hu)=>{"use strict";var jh=_e().isSpace,Yi=[];for(Wi=0;Wi<256;Wi++)Yi.push(0);var Wi;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){Yi[r.charCodeAt(0)]=1});hu.exports=function(e,t){var n,o,s,i,a,l=e.pos,u=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=u))return!1;if(n=e.src.charCodeAt(l),n===10){for(t||e.push("hardbreak","br",0),l++;l<u&&(n=e.src.charCodeAt(l),!!jh(n));)l++;return e.pos=l,!0}return i=e.src[l],n>=55296&&n<=56319&&l+1<u&&(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&&Yi[n]!==0?a.content=i:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var gu=re((cy,mu)=>{"use strict";mu.exports=function(e,t){var n,o,s,i,a,l,u,c,f=e.pos,h=e.src.charCodeAt(f);if(h!==96)return!1;for(n=f,f++,o=e.posMax;f<o&&e.src.charCodeAt(f)===96;)f++;if(s=e.src.slice(n,f),u=s.length,e.backticksScanned&&(e.backticks[u]||0)<=n)return t||(e.pending+=s),e.pos+=u,!0;for(a=l=f;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<o&&e.src.charCodeAt(l)===96;)l++;if(c=l-a,c===u)return t||(i=e.push("code_inline","code",0),i.markup=s,i.content=e.src.slice(f,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[c]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=u,!0}});var Xi=re((dy,Ki)=>{"use strict";Ki.exports.tokenize=function(e,t){var n,o,s,i,a,l=e.pos,u=e.src.charCodeAt(l);if(t||u!==126||(o=e.scanDelims(e.pos,!0),i=o.length,a=String.fromCharCode(u),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:u,length:0,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function vu(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)}}Ki.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(vu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&vu(e,n[t].delimiters)}});var Qi=re((fy,Zi)=>{"use strict";Zi.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 yu(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--))}Zi.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(yu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&yu(e,n[t].delimiters)}});var xu=re((hy,bu)=>{"use strict";var Hh=_e().normalizeReference,Ji=_e().isSpace;bu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,h="",d="",p=e.pos,m=e.posMax,v=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<m&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(l>=m)return!1;if(v=l,u=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),u.ok){for(h=e.md.normalizeLink(u.str),e.md.validateLink(h)?l=u.pos:h="",v=l;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(u=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&v!==l&&u.ok)for(d=u.str,l=u.pos;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(v=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(v,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),c=e.env.references[Hh(s)],!c)return e.pos=p,!1;h=c.href,d=c.title}return t||(e.pos=a,e.posMax=i,f=e.push("link_open","a",1),f.attrs=n=[["href",h]],d&&n.push(["title",d]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,f=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Eu=re((py,wu)=>{"use strict";var qh=_e().normalizeReference,eo=_e().isSpace;wu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,h,d,p,m,v="",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(u=a+1,u<x&&e.src.charCodeAt(u)===40){for(u++;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(u>=x)return!1;for(m=u,f=e.md.helpers.parseLinkDestination(e.src,u,e.posMax),f.ok&&(v=e.md.normalizeLink(f.str),e.md.validateLink(v)?u=f.pos:v=""),m=u;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(f=e.md.helpers.parseLinkTitle(e.src,u,e.posMax),u<x&&m!==u&&f.ok)for(h=f.str,u=f.pos;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);else h="";if(u>=x||e.src.charCodeAt(u)!==41)return e.pos=b,!1;u++}else{if(typeof e.env.references>"u")return!1;if(u<x&&e.src.charCodeAt(u)===91?(m=u+1,u=e.md.helpers.parseLinkLabel(e,u),u>=0?i=e.src.slice(m,u++):u=a+1):u=a+1,i||(i=e.src.slice(l,a)),c=e.env.references[qh(i)],!c)return e.pos=b,!1;v=c.href,h=c.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),d=e.push("image","img",0),d.attrs=n=[["src",v],["alt",""]],d.children=p,d.content=s,h&&n.push(["title",h])),e.pos=u,e.posMax=x,!0}});var Cu=re((my,Su)=>{"use strict";var Vh=/^([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])?)*)$/,Gh=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Su.exports=function(e,t){var n,o,s,i,a,l,u=e.pos;if(e.src.charCodeAt(u)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++u>=l||(i=e.src.charCodeAt(u),i===60))return!1;if(i===62)break}return n=e.src.slice(a+1,u),Gh.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):Vh.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 ku=re((gy,Au)=>{"use strict";var Wh=Gi().HTML_TAG_RE;function Yh(r){return/^<a[>\s]/i.test(r)}function Kh(r){return/^<\/a\s*>/i.test(r)}function Xh(r){var e=r|32;return e>=97&&e<=122}Au.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&&!Xh(n))||(o=e.src.slice(a).match(Wh),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length),Yh(i.content)&&e.linkLevel++,Kh(i.content)&&e.linkLevel--),e.pos+=o[0].length,!0)}});var Lu=re((vy,Du)=>{"use strict";var Tu=_i(),Zh=_e().has,Qh=_e().isValidEntityCode,Iu=_e().fromCodePoint,Jh=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,ep=/^&([a-z][a-z0-9]{1,31});/i;Du.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(Jh),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=Qh(o)?Iu(o):Iu(65533),i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(ep),s&&Zh(Tu,s[1]))return t||(i=e.push("text_special","",0),i.content=Tu[s[1]],i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0;return!1}});var Ou=re((yy,Ru)=>{"use strict";function Fu(r,e){var t,n,o,s,i,a,l,u,c={},f=e.length;if(!!f){var h=0,d=-2,p=[];for(t=0;t<f;t++)if(o=e[t],p.push(0),(e[h].marker!==o.marker||d!==o.token-1)&&(h=t),d=o.token,o.length=o.length||0,!!o.close){for(c.hasOwnProperty(o.marker)||(c[o.marker]=[-1,-1,-1,-1,-1,-1]),i=c[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)){u=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+u,p[n]=u,o.open=!1,s.end=t,s.close=!1,a=-1,d=-2;break}a!==-1&&(c[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Ru.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(Fu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&Fu(e,n[t].delimiters)}});var Mu=re((by,Pu)=>{"use strict";Pu.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 Uu=re((xy,$u)=>{"use strict";var to=kn(),_u=_e().isWhiteSpace,Nu=_e().isPunctChar,Bu=_e().isMdAsciiPunct;function Ur(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}Ur.prototype.pushPending=function(){var r=new to("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};Ur.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new to(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};Ur.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,u,c,f,h=!0,d=!0,p=this.posMax,m=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===m;)t++;return s=t-r,o=t<p?this.src.charCodeAt(t):32,u=Bu(n)||Nu(String.fromCharCode(n)),f=Bu(o)||Nu(String.fromCharCode(o)),l=_u(n),c=_u(o),c?h=!1:f&&(l||u||(h=!1)),l?d=!1:u&&(c||f||(d=!1)),e?(i=h,a=d):(i=h&&(!d||u),a=d&&(!h||f)),{can_open:i,can_close:a,length:s}};Ur.prototype.Token=to;$u.exports=Ur});var Hu=re((wy,ju)=>{"use strict";var zu=Cn(),ro=[["text",lu()],["linkify",cu()],["newline",fu()],["escape",pu()],["backticks",gu()],["strikethrough",Xi().tokenize],["emphasis",Qi().tokenize],["link",xu()],["image",Eu()],["autolink",Cu()],["html_inline",ku()],["entity",Lu()]],no=[["balance_pairs",Ou()],["strikethrough",Xi().postProcess],["emphasis",Qi().postProcess],["fragments_join",Mu()]];function zr(){var r;for(this.ruler=new zu,r=0;r<ro.length;r++)this.ruler.push(ro[r][0],ro[r][1]);for(this.ruler2=new zu,r=0;r<no.length;r++)this.ruler2.push(no[r][0],no[r][1])}zr.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};zr.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()};zr.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)};zr.prototype.State=Uu();ju.exports=zr});var Vu=re((Ey,qu)=>{"use strict";qu.exports=function(r){var e={};r=r||{},e.src_Any=Bi().source,e.src_Cc=$i().source,e.src_Z=Ui().source,e.src_P=bn().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 Xu=re((Sy,Ku)=>{"use strict";function io(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 Rn(r){return Object.prototype.toString.call(r)}function tp(r){return Rn(r)==="[object String]"}function rp(r){return Rn(r)==="[object Object]"}function np(r){return Rn(r)==="[object RegExp]"}function Gu(r){return Rn(r)==="[object Function]"}function ip(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var Yu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function op(r){return Object.keys(r||{}).reduce(function(e,t){return e||Yu.hasOwnProperty(t)},!1)}var sp={"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}}},ap="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]",lp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function up(r){r.__index__=-1,r.__text_cache__=""}function cp(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function Wu(){return function(r,e){e.normalize(r)}}function Fn(r){var e=r.re=Vu()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(ap),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 u={validate:null,link:null};if(r.__compiled__[a]=u,rp(l)){np(l.validate)?u.validate=cp(l.validate):Gu(l.validate)?u.validate=l.validate:s(a,l),Gu(l.normalize)?u.normalize=l.normalize:l.normalize?s(a,l):u.normalize=Wu();return}if(tp(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:Wu()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(ip).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"),up(r)}function dp(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 oo(r,e){var t=new dp(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function yt(r,e){if(!(this instanceof yt))return new yt(r,e);e||op(r)&&(e=r,r={}),this.__opts__=io({},Yu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=io({},sp,r),this.__compiled__={},this.__tlds__=lp,this.__tlds_replaced__=!1,this.re={},Fn(this)}yt.prototype.add=function(e,t){return this.__schemas__[e]=t,Fn(this),this};yt.prototype.set=function(e){return this.__opts__=io(this.__opts__,e),this};yt.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,o,s,i,a,l,u,c;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:"]&&(u=e.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<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:"]&&(c=e.indexOf("@"),c>=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};yt.prototype.pretest=function(e){return this.re.pretest.test(e)};yt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};yt.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(oo(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(oo(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};yt.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,oo(this,0)):null};yt.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(),Fn(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Fn(this),this)};yt.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};yt.prototype.onCompile=function(){};Ku.exports=yt});var ic={};_d(ic,{decode:()=>uo,default:()=>bp,encode:()=>co,toASCII:()=>nc,toUnicode:()=>rc,ucs2decode:()=>lo,ucs2encode:()=>ec});function rr(r){throw new RangeError(mp[r])}function gp(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function Ju(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(pp,".");let o=r.split("."),s=gp(o,e).join(".");return n+s}function lo(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 Qu,fp,hp,pp,mp,so,Mt,ao,ec,vp,Zu,tc,uo,co,rc,nc,yp,bp,oc=Md(()=>{"use strict";Qu="-",fp=/^xn--/,hp=/[^\0-\x7E]/,pp=/[\x2E\u3002\uFF0E\uFF61]/g,mp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},so=36-1,Mt=Math.floor,ao=String.fromCharCode;ec=r=>String.fromCodePoint(...r),vp=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36},Zu=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},tc=function(r,e,t){let n=0;for(r=t?Mt(r/700):r>>1,r+=Mt(r/e);r>so*26>>1;n+=36)r=Mt(r/so);return Mt(n+(so+1)*r/(r+38))},uo=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(Qu);i<0&&(i=0);for(let a=0;a<i;++a)r.charCodeAt(a)>=128&&rr("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a<t;){let l=n;for(let c=1,f=36;;f+=36){a>=t&&rr("invalid-input");let h=vp(r.charCodeAt(a++));(h>=36||h>Mt((2147483647-n)/c))&&rr("overflow"),n+=h*c;let d=f<=s?1:f>=s+26?26:f-s;if(h<d)break;let p=36-d;c>Mt(2147483647/p)&&rr("overflow"),c*=p}let u=e.length+1;s=tc(n-l,u,l==0),Mt(n/u)>2147483647-o&&rr("overflow"),o+=Mt(n/u),n%=u,e.splice(n++,0,o)}return String.fromCodePoint(...e)},co=function(r){let e=[];r=lo(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(ao(l));let i=e.length,a=i;for(i&&e.push(Qu);a<t;){let l=2147483647;for(let c of r)c>=n&&c<l&&(l=c);let u=a+1;l-n>Mt((2147483647-o)/u)&&rr("overflow"),o+=(l-n)*u,n=l;for(let c of r)if(c<n&&++o>2147483647&&rr("overflow"),c==n){let f=o;for(let h=36;;h+=36){let d=h<=s?1:h>=s+26?26:h-s;if(f<d)break;let p=f-d,m=36-d;e.push(ao(Zu(d+p%m,0))),f=Mt(p/m)}e.push(ao(Zu(f,0))),s=tc(o,u,a==i),o=0,++a}++o,++n}return e.join("")},rc=function(r){return Ju(r,function(e){return fp.test(e)?uo(e.slice(4).toLowerCase()):e})},nc=function(r){return Ju(r,function(e){return hp.test(e)?"xn--"+co(e):e})},yp={version:"2.1.0",ucs2:{decode:lo,encode:ec},decode:uo,encode:co,toASCII:nc,toUnicode:rc},bp=yp});var ac=re((Cy,sc)=>{"use strict";sc.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 uc=re((Ay,lc)=>{"use strict";lc.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 dc=re((ky,cc)=>{"use strict";cc.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 mc=re((Ty,pc)=>{"use strict";var jr=_e(),xp=Ya(),wp=Xa(),Ep=Sl(),Sp=su(),Cp=Hu(),Ap=Xu(),nr=Ni(),fc=(oc(),Nd(ic)),kp={default:ac(),zero:uc(),commonmark:dc()},Tp=/^(vbscript|javascript|file|data):/,Ip=/^data:image\/(gif|png|jpeg|webp);/;function Dp(r){var e=r.trim().toLowerCase();return Tp.test(e)?!!Ip.test(e):!0}var hc=["http:","https:","mailto:"];function Lp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toASCII(e.hostname)}catch{}return nr.encode(nr.format(e))}function Fp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toUnicode(e.hostname)}catch{}return nr.decode(nr.format(e),nr.decode.defaultChars+"%")}function St(r,e){if(!(this instanceof St))return new St(r,e);e||jr.isString(r)||(e=r||{},r="default"),this.inline=new Cp,this.block=new Sp,this.core=new Ep,this.renderer=new wp,this.linkify=new Ap,this.validateLink=Dp,this.normalizeLink=Lp,this.normalizeLinkText=Fp,this.utils=jr,this.helpers=jr.assign({},xp),this.options={},this.configure(r),e&&this.set(e)}St.prototype.set=function(r){return jr.assign(this.options,r),this};St.prototype.configure=function(r){var e=this,t;if(jr.isString(r)&&(t=r,r=kp[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};St.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};St.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};St.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};St.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};St.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};St.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};St.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};pc.exports=St});var vc=re((Iy,gc)=>{"use strict";gc.exports=mc()});var Ec=re((Dy,wc)=>{var fo=!0,bc=!1,xc=!1;wc.exports=function(r,e){e&&(fo=!e.enabled,bc=!!e.label,xc=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o<n.length;o++)Op(n,o)&&(Pp(n[o],t.Token),yc(n[o-2],"class","task-list-item"+(fo?"":" enabled")),yc(n[Rp(n,o-2)],"class","contains-task-list"))})};function yc(r,e,t){var n=r.attrIndex(e),o=[e,t];n<0?r.attrPush(o):r.attrs[n]=o}function Rp(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 Op(r,e){return $p(r[e])&&Up(r[e-1])&&zp(r[e-2])&&jp(r[e])}function Pp(r,e){if(r.children.unshift(Mp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),bc)if(xc){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(Bp(r.content,t,e))}else r.children.unshift(_p(e)),r.children.push(Np(e))}function Mp(r,e){var t=new e("html_inline","",0),n=fo?' 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 _p(r){var e=new r("html_inline","",0);return e.content="<label>",e}function Np(r){var e=new r("html_inline","",0);return e.content="</label>",e}function Bp(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 $p(r){return r.type==="inline"}function Up(r){return r.type==="paragraph_open"}function zp(r){return r.type==="list_item_open"}function jp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var _c=re((Gr,Io)=>{(function(r,e){typeof Gr=="object"&&typeof Io=="object"?Io.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Gr=="object"?Gr.ClipboardJS=e():r.ClipboardJS=e()})(Gr,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return A}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),u=s.n(l);function c(O){try{return document.execCommand(O)}catch{return}}var f=function(O){return O=u()(O),c("cut"),O};function h(P,k){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 k.container.appendChild(P),k=u()(P),c("copy"),P.remove(),k}var d=function(O){var k=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof O=="string"?D=h(O,k):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O?.type)?D=h(O.value,k):(D=u()(O),c("copy")),D};function p(O){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k})(O)}var m=function(){var I=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=I.action,O=D===void 0?"copy":D,k=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?d(I,{container:k}):D?O==="cut"?f(D):d(D,{container:k}):void 0};function v(O){return(v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k})(O)}function b(O,k){for(var D=0;D<k.length;D++){var I=k[D];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(O,I.key,I)}}function x(O,k){return(x=Object.setPrototypeOf||function(D,I){return D.__proto__=I,D})(O,k)}function C(O){var k=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=S(O);return D=k?(D=S(this).constructor,Reflect.construct(I,arguments,D)):I.apply(this,arguments),I=this,!(D=D)||v(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 S(O){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(k){return k.__proto__||Object.getPrototypeOf(k)})(O)}function M(O,k){if(O="data-clipboard-".concat(O),k.hasAttribute(O))return k.getAttribute(O)}var A=function(){(function(N,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function");N.prototype=Object.create(B&&B.prototype,{constructor:{value:N,writable:!0,configurable:!0}}),B&&x(N,B)})(P,i());var O,k,D,I=C(P);function P(N,B){var H;return function(Z){if(!(Z instanceof P))throw new TypeError("Cannot call a class as a function")}(this),(H=I.call(this)).resolveOptions(B),H.listenClick(N),H}return O=P,D=[{key:"copy",value:function(N){var B=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return d(N,B)}},{key:"cut",value:function(N){return f(N)}},{key:"isSupported",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],N=typeof N=="string"?[N]:N,B=!!document.queryCommandSupported;return N.forEach(function(H){B=B&&!!document.queryCommandSupported(H)}),B}}],(k=[{key:"resolveOptions",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=v(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var B=this;this.listener=a()(N,"click",function(H){return B.onClick(H)})}},{key:"onClick",value:function(Z){var B=Z.delegateTarget||Z.currentTarget,H=this.action(B)||"copy",Z=m({action:H,container:this.container,target:this.target(B),text:this.text(B)});this.emit(Z?"success":"error",{action:H,text:Z,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return M("action",N)}},{key:"defaultTarget",value:function(N){if(N=M("target",N),N)return document.querySelector(N)}},{key:"defaultText",value:function(N){return M("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(O.prototype,k),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,u,c,f,h){var d=function(p,m,v,b){return function(x){x.delegateTarget=i(x.target,m),x.delegateTarget&&b.call(p,x)}}.apply(this,arguments);return l.addEventListener(c,d,h),{destroy:function(){l.removeEventListener(c,d,h)}}}n.exports=function(l,u,c,f,h){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof c=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(d){return a(d,u,c,f,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,u,c){if(!l&&!u&&!c)throw new Error("Missing required arguments");if(!i.string(u))throw new TypeError("Second argument must be a String");if(!i.fn(c))throw new TypeError("Third argument must be a Function");if(i.node(l))return m=u,v=c,(p=l).addEventListener(m,v),{destroy:function(){p.removeEventListener(m,v)}};if(i.nodeList(l))return f=l,h=u,d=c,Array.prototype.forEach.call(f,function(b){b.addEventListener(h,d)}),{destroy:function(){Array.prototype.forEach.call(f,function(b){b.removeEventListener(h,d)})}};if(i.string(l))return l=l,u=u,c=c,a(document.body,l,u,c);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var f,h,d,p,m,v}},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 u(){l.off(s,u),i.apply(a,arguments)}return u._=i,this.on(s,u,a)},emit:function(s){for(var i=[].slice.call(arguments,1),a=((this.e||(this.e={}))[s]||[]).slice(),l=0,u=a.length;l<u;l++)a[l].fn.apply(a[l].ctx,i);return this},off:function(s,i){var a=this.e||(this.e={}),l=a[s],u=[];if(l&&i)for(var c=0,f=l.length;c<f;c++)l[c].fn!==i&&l[c].fn._!==i&&u.push(l[c]);return u.length?a[s]=u: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 Sr={},Bd=[];function Kr(r,e){if(Bd.push({name:r,data:e}),typeof Sr[r]>"u")return this;let t=Sr[r];for(let n=0;n<t.length;n++)t[n](e)}function $d(r,e){typeof Sr[r]>"u"&&(Sr[r]=[]),Sr[r].push(e)}function Ud(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function zd(r){if(!!r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
-`);Kr("error",e)}}var Jo={emit:Kr,emitPublic:Ud,listen:$d,success:r=>Kr("success",r),error:r=>Kr("error",r),showValidationErrors:zd};async function jd(r,e={}){return es(r,{method:"GET",params:e})}async function Hd(r,e=null){return Xr("POST",r,e)}async function qd(r,e=null){return Xr("PUT",r,e)}async function Vd(r,e=null){return Xr("PATCH",r,e)}async function Gd(r,e=null){return Xr("DELETE",r,e)}async function Xr(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"),es(e,n)}async function es(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),s={data:await Wd(n),headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,url:n.url,original:n};if(!n.ok)throw s;return s}async function Wd(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 ts={get:jd,post:Hd,put:qd,patch:Vd,delete:Gd};var Un=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 u=l.match(s);if(u!==null&&Number(u[1])===t){a=l.replace(s,"").trim();break}let c=l.match(i);if(c!==null&&Number(c[1])<=t&&(c[2]==="*"||Number(c[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}},rs=Un;function Zr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Qr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Be(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 Jr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function qe(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function ns(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 Cr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function is(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ar(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 kr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=document.getElementById("custom-styles").getAttribute("data-color-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 ss(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function as(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var zn=class{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)),qe(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=as(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},ls=zn;var jn=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Be(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})}},us=jn;var Hn=class{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}Jr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Be(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}},cs=Hn;var qn=class{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(),this.mainTabs.components.tabs.show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.list.innerHTML=e.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"),Cr(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")}},ds=qn;var Vn=class{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")}},fs=Vn;var Gn={},Wn=class{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)),qe(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),qe(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),o=t[n+(e?1:-1)];o&&o.focus()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.slice(0,3).toLowerCase(),n=await this.loadSuggestions(t,e),o=n.slice(0,6);t.length>0&&(o=n.filter(s=>s.toLowerCase().includes(t)).slice(0,6)),this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){let n={search:e,name:t},o=`${this.url}:${JSON.stringify(n)}`;if(Gn[o])return Gn[o];let s=await window.$http.get(this.url,n);return Gn[o]=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">${ss(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()}},hs=Wn;var Yn=class{constructor(e){if(this.elem=e,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.elem.style.display="none";return}this.elem.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.elem.style.display="block",this.showing=!0,setTimeout(()=>{this.elem.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.elem.style.opacity=0,this.showing=!1,setTimeout(()=>{this.elem.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))}},ps=Yn;function ms(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 Rt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ms(Object(t),!0).forEach(function(n){Yd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ms(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function on(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?on=function(e){return typeof e}:on=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(r)}function Yd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function jt(){return jt=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},jt.apply(this,arguments)}function Kd(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 Xd(r,e){if(r==null)return{};var t=Kd(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}var Zd="1.15.0";function zt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Ht=zt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Mr=zt(/Edge/i),gs=zt(/firefox/i),Lr=zt(/safari/i)&&!zt(/chrome/i)&&!zt(/android/i),Cs=zt(/iP(ad|od|hone)/i),As=zt(/chrome/i)&&zt(/android/i),ks={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!Ht&&ks)}function Le(r,e,t){r.removeEventListener(e,t,!Ht&&ks)}function cn(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 Qd(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Lt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&cn(r,e):cn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Qd(r))}return null}var vs=/\s+/g;function mt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(vs," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(vs," ")}}function ge(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=ge(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 Ts(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 Ft(){var r=document.scrollingElement;return r||document.documentElement}function tt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,u,c,f;if(r!==window&&r.parentNode&&r!==Ft()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,u=s.right,c=s.height,f=s.width):(i=0,a=0,l=window.innerHeight,u=window.innerWidth,c=window.innerHeight,f=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!Ht))do if(o&&o.getBoundingClientRect&&(ge(o,"transform")!=="none"||t&&ge(o,"position")!=="static")){var h=o.getBoundingClientRect();i-=h.top+parseInt(ge(o,"border-top-width")),a-=h.left+parseInt(ge(o,"border-left-width")),l=i+s.height,u=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var d=dr(o||r),p=d&&d.a,m=d&&d.d;d&&(i/=m,a/=p,f/=p,c/=m,l=i+c,u=a+f)}return{top:i,left:a,bottom:l,right:u,width:f,height:c}}}function ys(r,e,t){for(var n=Kt(r,!0),o=tt(r)[e];n;){var s=tt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ft())break;n=Kt(n,!1)}return!1}function fr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ve.ghost&&(n||i[s]!==ve.dragged)&&Lt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function li(r,e){for(var t=r.lastElementChild;t&&(t===ve.ghost||ge(t,"display")==="none"||e&&!cn(t,e));)t=t.previousElementSibling;return t||null}function Et(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ve.clone&&(!e||cn(r,e))&&t++;return t}function bs(r){var e=0,t=0,n=Ft();if(r)do{var o=dr(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 Jd(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 Kt(r,e){if(!r||!r.getBoundingClientRect)return Ft();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ge(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 Ft();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ft()}function ef(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Kn(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 Fr;function Is(r,e){return function(){if(!Fr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Fr=setTimeout(function(){Fr=void 0},e)}}}function tf(){clearTimeout(Fr),Fr=void 0}function Ds(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Ls(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)}var vt="Sortable"+new Date().getTime();function rf(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ge(o,"display")==="none"||o===ve.ghost)){r.push({target:o,rect:tt(o)});var s=Rt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=dr(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(Jd(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,u=a.target,c=u.fromRect,f=tt(u),h=u.prevFromRect,d=u.prevToRect,p=a.rect,m=dr(u,!0);m&&(f.top-=m.f,f.left-=m.e),u.toRect=f,u.thisAnimationDuration&&Kn(h,f)&&!Kn(c,f)&&(p.top-f.top)/(p.left-f.left)===(c.top-f.top)/(c.left-f.left)&&(l=of(p,h,d,o.options)),Kn(f,c)||(u.prevFromRect=c,u.prevToRect=f,l||(l=o.options.animation),o.animate(u,p,f,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(u.animationResetTimer),u.animationResetTimer=setTimeout(function(){u.animationTime=0,u.prevFromRect=null,u.fromRect=null,u.prevToRect=null,u.thisAnimationDuration=null},l),u.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){ge(n,"transition",""),ge(n,"transform","");var a=dr(this.el),l=a&&a.a,u=a&&a.d,c=(o.left-s.left)/(l||1),f=(o.top-s.top)/(u||1);n.animatingX=!!c,n.animatingY=!!f,ge(n,"transform","translate3d("+c+"px,"+f+"px,0)"),this.forRepaintDummy=nf(n),ge(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ge(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ge(n,"transition",""),ge(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function nf(r){return r.offsetWidth}function of(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 ar=[],Xn={initializeByDefault:!0},_r={mount:function(e){for(var t in Xn)Xn.hasOwnProperty(t)&&!(t in e)&&(e[t]=Xn[t]);ar.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ar.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";ar.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Rt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Rt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){ar.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var u=new a(e,t,e.options);u.sortable=e,u.options=e.options,e[l]=u,jt(n,u.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 ar.forEach(function(o){typeof o.eventProperties=="function"&&jt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return ar.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function sf(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,u=r.newIndex,c=r.oldDraggableIndex,f=r.newDraggableIndex,h=r.originalEvent,d=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[vt],!!e){var m,v=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Ht&&!Mr?m=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(n,!0,!0)),m.to=i||t,m.from=a||t,m.item=o||t,m.clone=s,m.oldIndex=l,m.newIndex=u,m.oldDraggableIndex=c,m.newDraggableIndex=f,m.originalEvent=h,m.pullMode=d?d.lastPutMode:void 0;var x=Rt(Rt({},p),_r.getEventProperties(n,e));for(var C in x)m[C]=x[C];t&&t.dispatchEvent(m),v[b]&&v[b].call(e,m)}}var af=["evt"],ht=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Xd(n,af);_r.pluginEvent.bind(ve)(e,t,Rt({dragEl:ee,parentEl:Ze,ghostEl:we,rootEl:Ve,nextEl:er,lastDownEl:sn,cloneEl:Ye,cloneHidden:Yt,dragStarted:Tr,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt,hideGhostForTarget:Ps,unhideGhostForTarget:Ms,cloneNowHidden:function(){Yt=!0},cloneNowShown:function(){Yt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){sf(Rt({putSortable:it,cloneEl:Ye,targetEl:ee,rootEl:Ve,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt},r))}var ee,Ze,we,Ve,er,sn,Ye,Yt,cr,gt,Rr,Wt,en,it,ur=!1,dn=!1,fn=[],Qt,At,Zn,Qn,xs,ws,Tr,lr,Or,Pr=!1,tn=!1,an,lt,Jn=[],ii=!1,hn=[],mn=typeof document<"u",rn=Cs,Es=Mr||Ht?"cssFloat":"float",lf=mn&&!As&&!Cs&&"draggable"in document.createElement("div"),Fs=function(){if(!!mn){if(Ht)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Rs=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=fr(e,0,t),i=fr(e,1,t),a=s&&ge(s),l=i&&ge(i),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+tt(s).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+tt(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 f=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===f)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=o&&n[Es]==="none"||i&&n[Es]==="none"&&u+c>o)?"vertical":"horizontal"},uf=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,u=n?t.width:t.height;return o===a||s===l||o+i/2===a+u/2},cf=function(e,t){var n;return fn.some(function(o){var s=o[vt].options.emptyInsertThreshold;if(!(!s||li(o))){var i=tt(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},Os=function(e){function t(s,i){return function(a,l,u,c){var f=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||f))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,u,c),i)(a,l,u,c);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||on(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},Ps=function(){!Fs&&we&&ge(we,"display","none")},Ms=function(){!Fs&&we&&ge(we,"display","")};mn&&!As&&document.addEventListener("click",function(r){if(dn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),dn=!1,!1},!0);var Jt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=cf(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[vt]._onDragOver(n)}}},df=function(e){ee&&ee.parentNode[vt]._isOutsideThisEl(e.target)};function ve(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=jt({},e),r[vt]=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 Rs(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:ve.supportPointer!==!1&&"PointerEvent"in window&&!Lr,emptyInsertThreshold:5};_r.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);Os(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:lf,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Me(r,"pointerdown",this._onTapStart):(Me(r,"mousedown",this._onTapStart),Me(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(Me(r,"dragover",this),Me(r,"dragenter",this)),fn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),jt(this,rf())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(lr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,ee):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,u=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=o.filter;if(bf(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Lr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Lt(l,o.draggable,n,!1),!(l&&l.animated)&&sn!==l)){if(cr=Et(l),Rr=Et(l,o.draggable),typeof c=="function"){if(c.call(this,e,l,this)){ct({sortable:t,rootEl:u,name:"filter",targetEl:l,toEl:n,fromEl:n}),ht("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(c&&(c=c.split(",").some(function(f){if(f=Lt(u,f.trim(),n,!1),f)return ct({sortable:t,rootEl:f,name:"filter",targetEl:l,fromEl:n,toEl:n}),ht("filter",t,{evt:e}),!0}),c)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Lt(u,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&&!ee&&n.parentNode===s){var u=tt(n);if(Ve=s,ee=n,Ze=ee.parentNode,er=ee.nextSibling,sn=n,en=i.group,ve.dragged=ee,Qt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},xs=Qt.clientX-u.left,ws=Qt.clientY-u.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,ee.style["will-change"]="all",l=function(){if(ht("delayEnded",o,{evt:e}),ve.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!gs&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),mt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){Ts(ee,c.trim(),ei)}),Me(a,"dragover",Jt),Me(a,"mousemove",Jt),Me(a,"touchmove",Jt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),gs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Mr||Ht))){if(ve.eventCanceled){this._onDrop();return}Me(a,"mouseup",o._disableDelayedDrag),Me(a,"touchend",o._disableDelayedDrag),Me(a,"touchcancel",o._disableDelayedDrag),Me(a,"mousemove",o._delayedDragTouchMoveHandler),Me(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&Me(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(){ee&&ei(ee),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._disableDelayedDrag),Le(e,"touchend",this._disableDelayedDrag),Le(e,"touchcancel",this._disableDelayedDrag),Le(e,"mousemove",this._delayedDragTouchMoveHandler),Le(e,"touchmove",this._delayedDragTouchMoveHandler),Le(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Me(document,"pointermove",this._onTouchMove):t?Me(document,"touchmove",this._onTouchMove):Me(document,"mousemove",this._onTouchMove):(Me(ee,"dragend",this),Me(Ve,"dragstart",this._onDragStart));try{document.selection?ln(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ur=!1,Ve&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",df);var n=this.options;!e&&mt(ee,n.dragClass,!1),mt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(At){this._lastX=At.clientX,this._lastY=At.clientY,Ps();for(var e=document.elementFromPoint(At.clientX,At.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(At.clientX,At.clientY),e!==t);)t=e;if(ee.parentNode[vt]._isOutsideThisEl(e),t)do{if(t[vt]){var n=void 0;if(n=t[vt]._onDragOver({clientX:At.clientX,clientY:At.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ms()}},_onTouchMove:function(e){if(Qt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&dr(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=rn&<&&bs(lt),c=(s.clientX-Qt.clientX+o.x)/(a||1)+(u?u[0]-Jn[0]:0)/(a||1),f=(s.clientY-Qt.clientY+o.y)/(l||1)+(u?u[1]-Jn[1]:0)/(l||1);if(!ve.active&&!ur){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(we){i?(i.e+=c-(Zn||0),i.f+=f-(Qn||0)):i={a:1,b:0,c:0,d:1,e:c,f};var h="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ge(we,"webkitTransform",h),ge(we,"mozTransform",h),ge(we,"msTransform",h),ge(we,"transform",h),Zn=c,Qn=f,At=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!we){var e=this.options.fallbackOnBody?document.body:Ve,t=tt(ee,!0,rn,!0,e),n=this.options;if(rn){for(lt=e;ge(lt,"position")==="static"&&ge(lt,"transform")==="none"&<!==document;)lt=lt.parentNode;lt!==document.body&<!==document.documentElement?(lt===document&&(lt=Ft()),t.top+=lt.scrollTop,t.left+=lt.scrollLeft):lt=Ft(),Jn=bs(lt)}we=ee.cloneNode(!0),mt(we,n.ghostClass,!1),mt(we,n.fallbackClass,!0),mt(we,n.dragClass,!0),ge(we,"transition",""),ge(we,"transform",""),ge(we,"box-sizing","border-box"),ge(we,"margin",0),ge(we,"top",t.top),ge(we,"left",t.left),ge(we,"width",t.width),ge(we,"height",t.height),ge(we,"opacity","0.8"),ge(we,"position",rn?"absolute":"fixed"),ge(we,"zIndex","100000"),ge(we,"pointerEvents","none"),ve.ghost=we,e.appendChild(we),ge(we,"transform-origin",xs/parseInt(we.style.width)*100+"% "+ws/parseInt(we.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(ht("dragStart",this,{evt:e}),ve.eventCanceled){this._onDrop();return}ht("setupClone",this),ve.eventCanceled||(Ye=Ls(ee),Ye.removeAttribute("id"),Ye.draggable=!1,Ye.style["will-change"]="",this._hideClone(),mt(Ye,this.options.chosenClass,!1),ve.clone=Ye),n.cloneId=ln(function(){ht("clone",n),!ve.eventCanceled&&(n.options.removeCloneOnHide||Ve.insertBefore(Ye,ee),n._hideClone(),ct({sortable:n,name:"clone"}))}),!t&&mt(ee,s.dragClass,!0),t?(dn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Le(document,"mouseup",n._onDrop),Le(document,"touchend",n._onDrop),Le(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,ee)),Me(document,"drop",n),ge(ee,"transform","translateZ(0)")),ur=!0,n._dragStartId=ln(n._dragStarted.bind(n,t,e)),Me(document,"selectstart",n),Tr=!0,Lr&&ge(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,u=ve.active,c=en===l,f=a.sort,h=it||u,d,p=this,m=!1;if(ii)return;function v(ne,be){ht(ne,p,Rt({evt:e,isOwner:c,axis:d?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:f,fromSortable:h,target:n,completed:x,onMove:function(xe,Fe){return nn(Ve,t,ee,o,xe,tt(xe),e,Fe)},changed:C},be))}function b(){v("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ne){return v("dragOverCompleted",{insertion:ne}),ne&&(c?u._hideClone():u._showClone(p),p!==h&&(mt(ee,it?it.options.ghostClass:u.options.ghostClass,!1),mt(ee,a.ghostClass,!0)),it!==p&&p!==ve.active?it=p:p===ve.active&&it&&(it=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){v("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===ee&&!ee.animated||n===t&&!n.animated)&&(lr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(ee.parentNode[vt]._isOutsideThisEl(e.target),!ne&&Jt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function C(){gt=Et(ee),Wt=Et(ee,a.draggable),ct({sortable:p,name:"change",toEl:t,newIndex:gt,newDraggableIndex:Wt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Lt(n,a.draggable,t,!0),v("dragOver"),ve.eventCanceled)return m;if(ee.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(dn=!1,u&&!a.disabled&&(c?f||(i=Ze!==Ve):it===this||(this.lastPutMode=en.checkPull(this,u,ee,e))&&l.checkPut(this,u,ee,e))){if(d=this._getDirection(e,n)==="vertical",o=tt(ee),v("dragOverValid"),ve.eventCanceled)return m;if(i)return Ze=Ve,b(),this._hideClone(),v("revert"),ve.eventCanceled||(er?Ve.insertBefore(ee,er):Ve.appendChild(ee)),x(!0);var S=li(t,a.draggable);if(!S||mf(e,d,this)&&!S.animated){if(S===ee)return x(!1);if(S&&t===e.target&&(n=S),n&&(s=tt(n)),nn(Ve,t,ee,o,n,s,e,!!n)!==!1)return b(),S&&S.nextSibling?t.insertBefore(ee,S.nextSibling):t.appendChild(ee),Ze=t,C(),x(!0)}else if(S&&pf(e,d,this)){var M=fr(t,0,a,!0);if(M===ee)return x(!1);if(n=M,s=tt(n),nn(Ve,t,ee,o,n,s,e,!1)!==!1)return b(),t.insertBefore(ee,M),Ze=t,C(),x(!0)}else if(n.parentNode===t){s=tt(n);var A=0,O,k=ee.parentNode!==t,D=!uf(ee.animated&&ee.toRect||o,n.animated&&n.toRect||s,d),I=d?"top":"left",P=ys(n,"top","top")||ys(ee,"top","top"),N=P?P.scrollTop:void 0;lr!==n&&(O=s[I],Pr=!1,tn=!D&&a.invertSwap||k),A=gf(e,n,s,d,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,tn,lr===n);var B;if(A!==0){var H=Et(ee);do H-=A,B=Ze.children[H];while(B&&(ge(B,"display")==="none"||B===we))}if(A===0||B===n)return x(!1);lr=n,Or=A;var Z=n.nextElementSibling,W=!1;W=A===1;var te=nn(Ve,t,ee,o,n,s,e,W);if(te!==!1)return(te===1||te===-1)&&(W=te===1),ii=!0,setTimeout(hf,30),b(),W&&!Z?t.appendChild(ee):n.parentNode.insertBefore(ee,W?Z:n),P&&Ds(P,0,N-P.scrollTop),Ze=ee.parentNode,O!==void 0&&!tn&&(an=Math.abs(O-tt(n)[I])),C(),x(!0)}if(t.contains(ee))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Le(document,"mousemove",this._onTouchMove),Le(document,"touchmove",this._onTouchMove),Le(document,"pointermove",this._onTouchMove),Le(document,"dragover",Jt),Le(document,"mousemove",Jt),Le(document,"touchmove",Jt)},_offUpEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._onDrop),Le(e,"touchend",this._onDrop),Le(e,"pointerup",this._onDrop),Le(e,"touchcancel",this._onDrop),Le(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(gt=Et(ee),Wt=Et(ee,n.draggable),ht("drop",this,{evt:e}),Ze=ee&&ee.parentNode,gt=Et(ee),Wt=Et(ee,n.draggable),ve.eventCanceled){this._nulling();return}ur=!1,tn=!1,Pr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),oi(this.cloneId),oi(this._dragStartId),this.nativeDraggable&&(Le(document,"drop",this),Le(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Lr&&ge(document.body,"user-select",""),ge(ee,"transform",""),e&&(Tr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),we&&we.parentNode&&we.parentNode.removeChild(we),(Ve===Ze||it&&it.lastPutMode!=="clone")&&Ye&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),ee&&(this.nativeDraggable&&Le(ee,"dragend",this),ei(ee),ee.style["will-change"]="",Tr&&!ur&&mt(ee,it?it.options.ghostClass:this.options.ghostClass,!1),mt(ee,this.options.chosenClass,!1),ct({sortable:this,name:"unchoose",toEl:Ze,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ve!==Ze?(gt>=0&&(ct({rootEl:Ze,name:"add",toEl:Ze,fromEl:Ve,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Ze,originalEvent:e}),ct({rootEl:Ze,name:"sort",toEl:Ze,fromEl:Ve,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),it&&it.save()):gt!==cr&>>=0&&(ct({sortable:this,name:"update",toEl:Ze,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),ve.active&&((gt==null||gt===-1)&&(gt=cr,Wt=Rr),ct({sortable:this,name:"end",toEl:Ze,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),Ve=ee=Ze=we=er=Ye=sn=Yt=Qt=At=Tr=gt=Wt=cr=Rr=lr=Or=it=en=ve.dragged=ve.ghost=ve.clone=ve.active=null,hn.forEach(function(e){e.checked=!0}),hn.length=Zn=Qn=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),ff(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],Lt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||yf(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Lt(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 Lt(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=_r.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&Os(n)},destroy:function(){ht("destroy",this);var e=this.el;e[vt]=null,Le(e,"mousedown",this._onTapStart),Le(e,"touchstart",this._onTapStart),Le(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Le(e,"dragover",this),Le(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),fn.splice(fn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Yt){if(ht("hideClone",this),ve.eventCanceled)return;ge(Ye,"display","none"),this.options.removeCloneOnHide&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),Yt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Yt){if(ht("showClone",this),ve.eventCanceled)return;ee.parentNode==Ve&&!this.options.group.revertClone?Ve.insertBefore(Ye,ee):er?Ve.insertBefore(Ye,er):Ve.appendChild(Ye),this.options.group.revertClone&&this.animate(ee,Ye),ge(Ye,"display",""),Yt=!1}}};function ff(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function nn(r,e,t,n,o,s,i,a){var l,u=r[vt],c=u.options.onMove,f;return window.CustomEvent&&!Ht&&!Mr?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||tt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),c&&(f=c.call(u,l,i)),f}function ei(r){r.draggable=!1}function hf(){ii=!1}function pf(r,e,t){var n=tt(fr(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 mf(r,e,t){var n=tt(li(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 gf(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,u=n?t.height:t.width,c=n?t.top:t.left,f=n?t.bottom:t.right,h=!1;if(!i){if(a&&an<u*o){if(!Pr&&(Or===1?l>c+u*s/2:l<f-u*s/2)&&(Pr=!0),Pr)h=!0;else if(Or===1?l<c+an:l>f-an)return-Or}else if(l>c+u*(1-o)/2&&l<f-u*(1-o)/2)return vf(e)}return h=h||i,h&&(l<c+u*s/2||l>f-u*s/2)?l>c+u/2?1:-1:0}function vf(r){return Et(ee)<Et(r)?1:-1}function yf(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 bf(r){hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&hn.push(n)}}function ln(r){return setTimeout(r,0)}function oi(r){return clearTimeout(r)}mn&&Me(document,"touchmove",function(r){(ve.active||ur)&&r.cancelable&&r.preventDefault()});ve.utils={on:Me,off:Le,css:ge,find:Ts,is:function(e,t){return!!Lt(e,t,e,!1)},extend:ef,throttle:Is,closest:Lt,toggleClass:mt,clone:Ls,index:Et,nextTick:ln,cancelNextTick:oi,detectDirection:Rs,getChild:fr};ve.get=function(r){return r[vt]};ve.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&&(ve.utils=Rt(Rt({},ve.utils),n.utils)),_r.mount(n)})};ve.create=function(r,e){return new ve(r,e)};ve.version=Zd;var Je=[],Ir,si,ai=!1,ti,ri,pn,Dr;function xf(){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?Me(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Me(document,"pointermove",this._handleFallbackAutoScroll):n.touches?Me(document,"touchmove",this._handleFallbackAutoScroll):Me(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Le(document,"dragover",this._handleAutoScroll):(Le(document,"pointermove",this._handleFallbackAutoScroll),Le(document,"touchmove",this._handleFallbackAutoScroll),Le(document,"mousemove",this._handleFallbackAutoScroll)),Ss(),un(),tf()},nulling:function(){pn=si=Ir=ai=Dr=ti=ri=null,Je.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(pn=t,n||this.options.forceAutoScrollFallback||Mr||Ht||Lr){ni(t,this.options,a,n);var l=Kt(a,!0);ai&&(!Dr||s!==ti||i!==ri)&&(Dr&&Ss(),Dr=setInterval(function(){var u=Kt(document.elementFromPoint(s,i),!0);u!==l&&(l=u,un()),ni(t,o.options,u,n)},10),ti=s,ri=i)}else{if(!this.options.bubbleScroll||Kt(a,!0)===Ft()){un();return}ni(t,this.options,Kt(a,!1),!1)}}},jt(r,{pluginName:"scroll",initializeByDefault:!0})}function un(){Je.forEach(function(r){clearInterval(r.pid)}),Je=[]}function Ss(){clearInterval(Dr)}var ni=Is(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=Ft(),u=!1,c;si!==t&&(si=t,un(),Ir=e.scroll,c=e.scrollFn,Ir===!0&&(Ir=Kt(t,!0)));var f=0,h=Ir;do{var d=h,p=tt(d),m=p.top,v=p.bottom,b=p.left,x=p.right,C=p.width,S=p.height,M=void 0,A=void 0,O=d.scrollWidth,k=d.scrollHeight,D=ge(d),I=d.scrollLeft,P=d.scrollTop;d===l?(M=C<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),A=S<k&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=C<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),A=S<k&&(D.overflowY==="auto"||D.overflowY==="scroll"));var N=M&&(Math.abs(x-o)<=i&&I+C<O)-(Math.abs(b-o)<=i&&!!I),B=A&&(Math.abs(v-s)<=i&&P+S<k)-(Math.abs(m-s)<=i&&!!P);if(!Je[f])for(var H=0;H<=f;H++)Je[H]||(Je[H]={});(Je[f].vx!=N||Je[f].vy!=B||Je[f].el!==d)&&(Je[f].el=d,Je[f].vx=N,Je[f].vy=B,clearInterval(Je[f].pid),(N!=0||B!=0)&&(u=!0,Je[f].pid=setInterval(function(){n&&this.layer===0&&ve.active._onTouchMove(pn);var Z=Je[this.layer].vy?Je[this.layer].vy*a:0,W=Je[this.layer].vx?Je[this.layer].vx*a:0;typeof c=="function"&&c.call(ve.dragged.parentNode[vt],W,Z,r,pn,Je[this.layer].el)!=="continue"||Ds(Je[this.layer].el,W,Z)}.bind({layer:f}),24))),f++}while(e.bubbleScroll&&h!==l&&(h=Kt(h,!1)));ai=u}},30),_s=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 u=n||s;a();var c=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,f=document.elementFromPoint(c.clientX,c.clientY);l(),u&&!u.el.contains(f)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function ui(){}ui.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=fr(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:_s};jt(ui,{pluginName:"revertOnSpill"});function ci(){}ci.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:_s};jt(ci,{pluginName:"removeOnSpill"});ve.mount(new xf);ve.mount(ci,ui);var hr=ve;var Ns={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}},di=class{constructor(e){this.elem=e,this.sortContainer=e.querySelector("[book-sort-boxes]"),this.input=e.querySelector("[book-sort-input]");let t=e.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),window.$events.listen("entity-select-confirm",this.bookSelect.bind(this))}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=Ns[a];t&&n.includes(a)&&(l=function(u,c){return 0-Ns[a](u,c)});for(let u of i)Array.from(u.children).filter(f=>f.matches("li")).sort(l).forEach(f=>{u.appendChild(f)});e=a,this.updateMapInput()})}bookSelect(e){if(this.elem.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=document.createElement("div");s.innerHTML=o.data;let i=s.children[0];this.sortContainer.append(i),this.setupBookSortable(i)})}setupBookSortable(e){let t=[e.querySelector(".sort-list")];t.push(...e.querySelectorAll(".entity-list-item + ul"));let 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)new hr(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:this.updateMapInput.bind(this),dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"CTRL",selectedClass:"sortable-selected"})}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.elem.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 u=0;u<l.length;u++)o.push({id:l[u].getAttribute("data-id"),sort:u,parentChapter:a,type:"page",book:n})}},Bs=di;var gn=new WeakMap;function $s(r,e=400,t=null){Br(r),r.style.display="block",Nr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function vn(r,e=400,t=null){Br(r),Nr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function pr(r,e=400){Br(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"]};Nr(r,i,e,()=>{r.style.display="none"})}function mr(r,e=400){Br(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]};Nr(r,i,e)}function Us(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{Br(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),u=a.getPropertyValue("padding-bottom"),c={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,u]};Nr(r,c,e)}}function Nr(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),gn.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),gn.set(r,s)},15)}function Br(r){gn.has(r)&&gn.get(r)()}var fi=class{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"),mr(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),pr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}},zs=fi;var hi=class{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()}),Be(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),Jr(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Be(this.saveButton,e=>this.save()),qe(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"),qe(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("/settings/users/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.popup.components.popup.show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.popup.components.popup.hide(),this.addHistory()}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)}},js=hi;var pi=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},Hs=pi;var mi=class{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}},qs=mi;var gi=class{constructor(e){this.elem=e,this.trigger=e.querySelector("[collapsible-trigger]"),this.content=e.querySelector("[collapsible-content]"),this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.elem.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),mr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),pr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},Vs=gi;var vi=class{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Be(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 this.container.components.popup}sendResult(e){this.res&&(this.res(e),this.res=null)}},Gs=vi;var yi=class{constructor(e){this.elem=e,this.checkbox=e.querySelector("input[type=checkbox]"),this.display=e.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.elem.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.keyCode===32||e.keyCode===13)&&(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)}},Ws=yi;var bi=class{constructor(e){this.elem=e,this.dealtWith=!1,e.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.elem.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.elem)}),this.dealtWith=!0)}},Ys=bi;var xi=class{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.setupListeners(),this.hide=this.hide.bind(this)}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.direction==="right"?this.menu.style.right=`${t.right-t.width}px`:this.menu.style.left=`${t.left}px`,this.menu.style.width=`${t.width}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.bind(this)),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.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.container.appendChild(this.menu)),this.showing=!1}getFocusable(){return Array.from(this.menu.querySelectorAll('[tabindex]:not([tabindex="-1"]),[href],button,input:not([type=hidden])'))}focusNext(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}setupListeners(){this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Be(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&this.focusNext()});let e=t=>{t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"&&(this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation())};this.container.addEventListener("keydown",e),this.moveMenu&&this.menu.addEventListener("keydown",e),this.menu.addEventListener("keydown ",t=>{t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.hide())})}},Ks=xi;var wi=class{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=Ar(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=Us(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"}},Xs=wi;var Qs=Yr(Zs());var Si=class{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 Qs.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),vn(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)}},Js=Si;var Ci=class{constructor(e){this.elem=e,this.buttons=e.querySelectorAll("[toolbox-tab-button]"),this.contentElements=e.querySelectorAll("[toolbox-tab-content]"),this.toggleButton=e.querySelector("[toolbox-toggle]"),this.toggleButton.addEventListener("click",this.toggle.bind(this)),this.elem.addEventListener("click",t=>{let n=t.target.closest("[toolbox-tab-button]");if(n===null)return;let o=n.getAttribute("toolbox-tab-button");this.setActiveTab(o,!0)}),this.setActiveTab(this.contentElements[0].getAttribute("toolbox-tab-content"))}toggle(){this.elem.classList.toggle("open");let e=this.elem.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n=0,o=this.buttons.length;n<o;n++)this.buttons[n].classList.remove("active"),this.buttons[n].getAttribute("toolbox-tab-button")===e&&this.buttons[n].classList.add("active");for(let n=0,o=this.contentElements.length;n<o;n++)this.contentElements[n].style.display="none",this.contentElements[n].getAttribute("toolbox-tab-content")===e&&(this.contentElements[n].style.display="block");t&&!this.elem.classList.contains("open")&&this.toggle()}},ea=Ci;var Ai=class{constructor(e){this.permissionsTable=e.querySelector("[permissions-table]"),this.restrictedCheckbox=e.querySelector("[name=restricted]"),this.restrictedCheckbox.addEventListener("change",this.updateTableVisibility.bind(this))}updateTableVisibility(){this.permissionsTable.style.display=this.restrictedCheckbox.checked?null:"none"}},ta=Ai;var ki=class{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()}),Be(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=""}},ra=ki;var Ti=class{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.addButton=this.$refs.add,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()}),this.addButton&&this.addButton.addEventListener("click",t=>{this.selectedItemData&&(this.confirmSelection(this.selectedItemData),this.unselectAll())}),qe(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`/ajax/search/entities?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}},na=Ti;var Ii=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,window.EntitySelectorPopup=this,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.elem.components.popup.show(),this.getSelector().focusSearch()}hide(){this.elem.components.popup.hide()}getSelector(){return this.selectorEl.components["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)}},ia=Ii;var Di=class{setup(){this.container=this.$el,this.name=this.$opts.name,Be(this.$el,()=>{this.$emit(this.name,this.$opts)})}},oa=Di;var Li=class{constructor(e){this.elem=e,this.isOpen=e.getAttribute("expand-toggle-is-open")==="yes",this.updateEndpoint=e.getAttribute("expand-toggle-update-endpoint"),this.selector=e.getAttribute("expand-toggle"),e.addEventListener("click",this.click.bind(this))}open(e){mr(e,200)}close(e){pr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.selector);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"})}},sa=Li;var Fi=class{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)}},aa=Fi;var Ri=class{constructor(e){this.elem=e,this.typeControl=e.querySelector('[name="setting-app-homepage-type"]'),this.pagePickerContainer=e.querySelector("[page-picker-container]"),this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}},la=Ri;var Oi=class{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(),window.ImageManager=this}setupListeners(){Be(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()}),Be(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())}),qe(this.listContainer,".load-more","click",async e=>{Cr(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),Be(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),qe(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.popupEl.components.popup.show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.popupEl.components.popup.hide()}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),is(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){this.filterTabs.forEach(n=>n.classList.remove("selected"));let t=this.filterTabs.find(n=>n.dataset.filter===e);t&&t.classList.add("selected")}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(){Cr(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)}},ua=Oi;var Pi=class{constructor(e){this.elem=e,this.imageElem=e.querySelector("img"),this.imageInput=e.querySelector("input[type=file]"),this.resetInput=e.querySelector("input[data-reset-input]"),this.removeInput=e.querySelector("input[data-remove-input]"),this.defaultImage=e.getAttribute("data-default-image"),e.querySelector('button[data-action="reset-image"]').addEventListener("click",this.reset.bind(this));let n=e.querySelector('button[data-action="remove-image"]');n&&n.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")}},ca=Pi;var Mi=class{constructor(e){this.elem=e,this.menu=e.querySelector("ul"),this.sortInput=e.querySelector('[name="sort"]'),this.orderInput=e.querySelector('[name="order"]'),this.form=e.querySelector("form"),this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}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 n=this.orderInput.value==="asc"?"desc":"asc";this.orderInput.value=n,e.preventDefault(),this.form.submit()}},da=Mi;var Dc=Yr(vc()),Lc=Yr(Ec());var ho=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}},Hr=ho;function Hp(r,e){return document.createElement(r,e)}function qp(r,e,t){return document.createElementNS(r,e,t)}function Vp(){return document.createDocumentFragment()}function Gp(r){return document.createTextNode(r)}function Wp(r){return document.createComment(r)}function Yp(r,e,t){r.insertBefore(e,t)}function Kp(r,e){r.removeChild(e)}function Xp(r,e){r.appendChild(e)}function Zp(r){return r.parentNode}function Qp(r){return r.nextSibling}function Jp(r){return r.tagName}function em(r,e){r.textContent=e}function tm(r){return r.textContent}function rm(r){return r.nodeType===1}function nm(r){return r.nodeType===3}function im(r){return r.nodeType===8}function om(r){return r.nodeType===11}var On={createElement:Hp,createElementNS:qp,createTextNode:Gp,createDocumentFragment:Vp,createComment:Wp,insertBefore:Yp,removeChild:Kp,appendChild:Xp,parentNode:Zp,nextSibling:Qp,tagName:Jp,setTextContent:em,getTextContent:tm,isElement:rm,isText:nm,isComment:im,isDocumentFragment:om};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 Sc=Array.isArray;function Cc(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function po(r){return r===void 0}function pt(r){return r!==void 0}var mo=qt("",{},[],void 0,void 0);function qr(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);return r.sel===e.sel&&o&&s}function am(){throw new Error("The document fragment is not supported on this platform.")}function lm(r,e){return r.isElement(e)}function um(r,e){return r.isDocumentFragment(e)}function cm(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 dm=["create","update","remove","destroy","pre","post"];function go(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:On;for(let p of dm)for(let m of r){let v=m[p];v!==void 0&&n[p].push(v)}function s(p){let m=p.id?"#"+p.id:"",v=p.getAttribute("class"),b=v?"."+v.split(" ").join("."):"";return qt(o.tagName(p).toLowerCase()+m+b,{},[],void 0,p)}function i(p){return qt(void 0,{},[],void 0,p)}function a(p,m){return function(){if(--m===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,m){var v,b,x,C;let S,M=p.data;if(M!==void 0){let k=(v=M.hook)===null||v===void 0?void 0:v.init;pt(k)&&(k(p),M=p.data)}let A=p.children,O=p.sel;if(O==="!")po(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(O!==void 0){let k=O.indexOf("#"),D=O.indexOf(".",k),I=k>0?k:O.length,P=D>0?D:O.length,N=k!==-1||D!==-1?O.slice(0,Math.min(I,P)):O,B=p.elm=pt(M)&&pt(S=M.ns)?o.createElementNS(S,N,M):o.createElement(N,M);for(I<P&&B.setAttribute("id",O.slice(I+1,P)),D>0&&B.setAttribute("class",O.slice(P+1).replace(/\./g," ")),S=0;S<n.create.length;++S)n.create[S](mo,p);if(Sc(A))for(S=0;S<A.length;++S){let Z=A[S];Z!=null&&o.appendChild(B,l(Z,m))}else Cc(p.text)&&o.appendChild(B,o.createTextNode(p.text));let H=p.data.hook;pt(H)&&((b=H.create)===null||b===void 0||b.call(H,mo,p),H.insert&&m.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let k=p.children;for(p.elm=((C=o.createDocumentFragment)!==null&&C!==void 0?C:am)(),S=0;S<n.create.length;++S)n.create[S](mo,p);for(S=0;S<k.length;++S){let D=k[S];D!=null&&o.appendChild(p.elm,l(D,m))}}else p.elm=o.createTextNode(p.text);return p.elm}function u(p,m,v,b,x,C){for(;b<=x;++b){let S=v[b];S!=null&&o.insertBefore(p,l(S,C),m)}}function c(p){var m,v;let b=p.data;if(b!==void 0){(v=(m=b?.hook)===null||m===void 0?void 0:m.destroy)===null||v===void 0||v.call(m,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 C=p.children[x];C!=null&&typeof C!="string"&&c(C)}}}function f(p,m,v,b){for(var x,C;v<=b;++v){let S,M,A=m[v];if(A!=null)if(pt(A.sel)){c(A),S=n.remove.length+1,M=a(A.elm,S);for(let k=0;k<n.remove.length;++k)n.remove[k](A,M);let O=(C=(x=A?.data)===null||x===void 0?void 0:x.hook)===null||C===void 0?void 0:C.remove;pt(O)?O(A,M):M()}else o.removeChild(p,A.elm)}}function h(p,m,v,b){let x=0,C=0,S=m.length-1,M=m[0],A=m[S],O=v.length-1,k=v[0],D=v[O],I,P,N,B;for(;x<=S&&C<=O;)M==null?M=m[++x]:A==null?A=m[--S]:k==null?k=v[++C]:D==null?D=v[--O]:qr(M,k)?(d(M,k,b),M=m[++x],k=v[++C]):qr(A,D)?(d(A,D,b),A=m[--S],D=v[--O]):qr(M,D)?(d(M,D,b),o.insertBefore(p,M.elm,o.nextSibling(A.elm)),M=m[++x],D=v[--O]):qr(A,k)?(d(A,k,b),o.insertBefore(p,A.elm,M.elm),A=m[--S],k=v[++C]):(I===void 0&&(I=cm(m,x,S)),P=I[k.key],po(P)?o.insertBefore(p,l(k,b),M.elm):(N=m[P],N.sel!==k.sel?o.insertBefore(p,l(k,b),M.elm):(d(N,k,b),m[P]=void 0,o.insertBefore(p,N.elm,M.elm))),k=v[++C]);C<=O&&(B=v[O+1]==null?null:v[O+1].elm,u(p,B,v,C,O,b)),x<=S&&f(p,m,x,S)}function d(p,m,v){var b,x,C,S,M,A,O,k;let D=(b=m.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,m);let I=m.elm=p.elm,P=p.children,N=m.children;if(p!==m){if(m.data!==void 0||pt(m.text)&&m.text!==p.text){(C=m.data)!==null&&C!==void 0||(m.data={}),(S=p.data)!==null&&S!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,m);(O=(A=(M=m.data)===null||M===void 0?void 0:M.hook)===null||A===void 0?void 0:A.update)===null||O===void 0||O.call(A,p,m)}po(m.text)?pt(P)&&pt(N)?P!==N&&h(I,P,N,v):pt(N)?(pt(p.text)&&o.setTextContent(I,""),u(I,null,N,0,N.length-1,v)):pt(P)?f(I,P,0,P.length-1):pt(p.text)&&o.setTextContent(I,""):p.text!==m.text&&(pt(P)&&f(I,P,0,P.length-1),o.setTextContent(I,m.text)),(k=D?.postpatch)===null||k===void 0||k.call(D,p,m)}}return function(m,v){let b,x,C,S=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(lm(o,m)?m=s(m):um(o,m)&&(m=i(m)),qr(m,v)?d(m,v,S):(x=m.elm,C=o.parentNode(x),l(v,S),C!==null&&(o.insertBefore(C,v.elm,o.nextSibling(x)),f(C,[m],0,0))),b=0;b<S.length;++b)S[b].data.hook.insert(S[b]);for(b=0;b<n.post.length;++b)n.post[b]();return v}}function vo(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&&vo(s,o.children,o.sel)}}function Vr(r,e){let t=e!==void 0?e:On,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={},u={},c={},f=[],h,d,p,m=r.attributes,v=r.childNodes;for(d=0,p=m.length;d<p;d++)h=m[d].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?u[h.slice(5)]=m[d].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=m[d].nodeValue);for(d=0,p=v.length;d<p;d++)f.push(Vr(v[d],e));return Object.keys(l).length>0&&(c.attrs=l),Object.keys(u).length>0&&(c.datasets=u),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&vo(c,f,a),qt(a,c,f,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 fm="http://www.w3.org/1999/xlink",hm="http://www.w3.org/XML/1998/namespace";function Ac(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(hm,t,i):t.charCodeAt(5)===58?n.setAttributeNS(fm,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var yo={create:Ac,update:Ac};var Pn;function pm(){return Pn||(Pn=go([yo]),Pn)}function kc(r,e){let t=document.createElement("div");t.innerHTML=e,pm()(Vr(r),Vr(t))}var _t=null,wo,bo,xo;function mm(r,e,t){bo=e,xo=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tc),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),wo=new URL(r).origin}function gm(){Ic()}function Tc(r){if(!r.data||r.data.length<1||r.origin!==wo)return;let e=JSON.parse(r.data);e.event==="init"?bm():e.event==="exit"?Ic():e.event==="save"?ym(e):e.event==="export"?vm(e):e.event==="configure"&&xm()}function vm(r){xo&&xo(r.data)}function ym(r){Eo({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function bm(){!bo||bo().then(r=>{Eo({action:"load",autosave:1,xml:r})})}function xm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),Eo({action:"configure",config:r})}function Ic(){window.removeEventListener("message",Tc),_t&&document.body.removeChild(_t)}function Eo(r){_t.contentWindow.postMessage(JSON.stringify(r),wo)}async function wm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function Em(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var bt={show:mm,close:gm,upload:wm,load:Em};var So=class{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.markdown=new Dc.default({html:!0}),this.markdown.use(Lc.default,{label:!0}),this.display=this.elem.querySelector(".markdown-display"),this.displayStylesLoaded=!1,this.input=this.elem.querySelector("textarea"),this.cm=null,this.Code=null;let e=window.importVersioned("code").then(n=>(this.cm=n.markdownEditor(this.input),this.Code=n,this.cm));this.onMarkdownScroll=this.onMarkdownScroll.bind(this);let t=()=>{this.displayDoc=this.display.contentDocument,this.init(e)};this.display.contentDocument.readyState==="complete"?t():this.display.addEventListener("load",t.bind(this)),window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.markdown,displayEl:this.display,codeMirrorInstance:this.cm})}init(e){let t=0;this.displayDoc.addEventListener("click",s=>{let i=Date.now()-t<300,a=s.target.closest("a");if(a!==null){s.preventDefault(),window.open(a.getAttribute("href"));return}let l=s.target.closest("[drawio-diagram]");if(l!==null&&i){this.actionEditDrawing(l);return}t=Date.now()}),this.elem.addEventListener("click",s=>{let i=s.target.closest("button[data-action]");if(i===null)return;let a=i.getAttribute("data-action");if(a==="insertImage"&&this.actionInsertImage(),a==="insertLink"&&this.actionShowLinkSelector(),a==="insertDrawing"&&(s.ctrlKey||s.metaKey)){this.actionShowImageManager();return}a==="insertDrawing"&&this.actionStartDrawing(),a==="fullscreen"&&this.actionFullScreen()}),this.elem.addEventListener("click",s=>{let i=s.target.closest(".editor-toolbar-label");if(!i)return;let a=this.elem.querySelectorAll(".markdown-editor-wrap");for(let l of a)l.classList.remove("active");i.closest(".markdown-editor-wrap").classList.add("active")}),e.then(s=>{this.codeMirrorSetup(s);let i=Ar(()=>this.Code.updateLayout(s),100,!1);new ResizeObserver(i).observe(this.elem)}),this.listenForBookStackEditorEvents();let o=new URL(window.location).searchParams.get("content-text");o&&this.scrollToText(o)}updateAndRender(){let e=this.cm.getValue();this.input.value=e;let t=this.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e);let n=this.getDisplayTarget();this.displayDoc.body.className="page-content",kc(n,t),this.loadStylesIntoDisplay()}getDisplayTarget(){let e=this.displayDoc.body;if(e.children.length===0){let t=document.createElement("div");this.displayDoc.body.append(t)}return e.children[0]}loadStylesIntoDisplay(){if(this.displayStylesLoaded)return;this.displayDoc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.displayDoc.documentElement.style.backgroundColor="#222",this.displayDoc.documentElement.classList.add("dark-mode")),this.displayDoc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.displayDoc.head.appendChild(n)}this.displayStylesLoaded=!0}onMarkdownScroll(e){let t=this.displayDoc.body.children;if(t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}codeMirrorSetup(e){let t=this;e.setOption("direction","ltr");let n=this.Code.getMetaKey(),o={};o[`${n}-Alt-I`]=function(d){let m=``,v=d.getCursor("from");d.replaceSelection(m),d.setCursor(v.line,v.ch+m.length-1)},o[`${n}-S`]=d=>{window.$events.emit("editor-save-draft")},o[`${n}-Enter`]=d=>{window.$events.emit("editor-save-page")},o[`Shift-${n}-K`]=d=>{this.actionShowLinkSelector()},o[`${n}-K`]=d=>{h()},o[`${n}-1`]=d=>{a("##")},o[`${n}-2`]=d=>{a("###")},o[`${n}-3`]=d=>{a("####")},o[`${n}-4`]=d=>{a("#####")},o[`${n}-5`]=d=>{a("")},o[`${n}-D`]=d=>{a("")},o[`${n}-6`]=d=>{a(">")},o[`${n}-Q`]=d=>{a(">")},o[`${n}-7`]=d=>{u("\n```\n","\n```")},o[`${n}-8`]=d=>{u("`","`")},o[`Shift-${n}-E`]=d=>{u("`","`")},o[`${n}-9`]=d=>{u('<p class="callout info">',"</p>")},o[`${n}-P`]=d=>{a("-")},o[`${n}-O`]=d=>{c()},e.setOption("extraKeys",o),e.on("change",(d,p)=>{this.updateAndRender()});let s=Ar(d=>{let p=d.getScrollInfo();if(p.top+p.clientHeight===p.height){this.onMarkdownScroll(-1);return}let v=d.lineAtHeight(p.top,"local"),b=d.getRange({line:0,ch:null},{line:v,ch:null}),S=new DOMParser().parseFromString(this.markdown.render(b),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(S.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,p)=>{let m=new Hr(p.clipboardData||p.dataTransfer);if(!m.hasItems()||m.containsTabularData())return;let v=m.getImages();for(let b of v)f(b)}),e.on("drop",(d,p)=>{let m=p.dataTransfer.getData("bookstack/template");if(m){let b=d.coordsChar({left:p.pageX,top:p.pageY});d.setCursor(b),p.preventDefault(),window.$http.get(`/templates/${m}`).then(x=>{let C=x.data.markdown||x.data.html;d.replaceSelection(C)})}let v=new Hr(p.dataTransfer);if(v.hasItems()&&v.getImages().length>0){let b=d.coordsChar({left:p.pageX,top:p.pageY});d.setCursor(b),p.stopPropagation(),p.preventDefault();let x=v.getImages();for(let C of x)f(C)}});function i(d,p){let m=e.getValue(),v=e.listSelections();e.setValue(m.replace(d,p)),e.setSelections(v)}function a(d){let p=e.getCursor(),m=e.getLine(p.line),v=m.length,b=m.split(" ")[0];if(b===d){m=m.replace(`${d} `,""),e.replaceRange(m,{line:p.line,ch:0},{line:p.line,ch:v}),e.setCursor({line:p.line,ch:p.ch-(d.length+1)});return}let x=/^[#>`]/.test(b),C=0;x?(C=d.length-b.length,m=m.replace(b,d).trim()):d!==""&&(C=d.length+1,m=d+" "+m),e.replaceRange(m,{line:p.line,ch:0},{line:p.line,ch:v}),e.setCursor({line:p.line,ch:p.ch+C})}function l(d,p){let m=e.getCursor(),v=e.getLine(m.line),b=v.length,x=v;v.indexOf(d)===0&&v.slice(-p.length)===p?x=v.slice(d.length,v.length-p.length):x=`${d}${v}${p}`,e.replaceRange(x,{line:m.line,ch:0},{line:m.line,ch:b}),e.setCursor({line:m.line,ch:m.ch+d.length})}function u(d,p){let m=e.getSelection();if(m==="")return l(d,p);let v=m,b=0,x=0;m.indexOf(d)===0&&m.slice(-p.length)===p?(v=m.slice(d.length,m.length-p.length),x=-(p.length+d.length)):(v=`${d}${m}${p}`,x=d.length+p.length);let C=e.listSelections()[0];e.replaceSelection(v);let S=C.head.ch<=C.anchor.ch;C.head.ch+=S?b:x,C.anchor.ch+=S?x:b,e.setSelections([C])}function c(){let d=e.getCursor(),m=(e.getLine(d.line-1)||"").match(/^(\s*)(\d)([).])\s/)||[],v=(Number(m[2])||0)+1,b=m[1]||"",x=m[3]||".",C=`${b}${v}${x}`;return a(C)}function f(d){if(d===null||d.type.indexOf("image")!==0)return;let p="png";if(d.name){let A=d.name.match(/\.(.+)$/);A.length>1&&(p=A[1])}let m="image-"+Math.random().toString(16).slice(2),v=window.baseUrl(`/loading.gif#upload${m}`),b=e.getSelection(),x=``,C=e.getCursor();e.replaceSelection(x),e.setCursor({line:C.line,ch:C.ch+b.length+3});let S="image-"+Date.now()+"."+p,M=new FormData;M.append("file",d,S),M.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",M).then(A=>{let O=`[](${A.data.url})`;i(x,O)}).catch(A=>{window.$events.emit("error",t.imageUploadErrorText),i(x,b),console.log(A)})}function h(){let d=e.getCursor("from"),p=e.getSelection()||"",m=`[${p}]()`;e.focus(),e.replaceSelection(m);let v=p===""?-3:-1;e.setCursor(d.line,d.ch+m.length+v)}this.updateAndRender()}actionInsertImage(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{let n=t.thumbs.display||t.url,o=this.cm.getSelection(),s="[]("+t.url+")";this.cm.focus(),this.cm.replaceSelection(s),this.cm.setCursor(e.line,e.ch+s.length)},"gallery")}actionShowImageManager(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{this.insertDrawing(t,e)},"drawio")}actionShowLinkSelector(){let e=this.cm.getCursor("from");window.EntitySelectorPopup.show(t=>{let o=`[${this.cm.getSelection()||t.name}](${t.link})`;this.cm.focus(),this.cm.replaceSelection(o),this.cm.setCursor(e.line,e.ch+o.length)})}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):!1}actionStartDrawing(){let e=this.getDrawioUrl();if(!e)return;let t=this.cm.getCursor("from");bt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),bt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.cm.focus(),this.cm.replaceSelection(n),this.cm.setCursor(t.line,t.ch+n.length)}actionEditDrawing(e){let t=this.getDrawioUrl();if(!t)return;let n=this.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");bt.show(t,()=>bt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,u=this.cm.getValue().split(`
+`,i.map=[t,e.line],!0}});var Ll=re((Wv,Dl)=>{"use strict";Dl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h=!1,d=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||d+3>p||(s=e.src.charCodeAt(d),s!==126&&s!==96)||(u=d,d=e.skipChars(d,s),i=d-u,i<3)||(f=e.src.slice(u,d),a=e.src.slice(d,p),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(o)return!0;for(l=t;l++,!(l>=n||(d=u=e.bMarks[l]+e.tShift[l],p=e.eMarks[l],d<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(d)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(d=e.skipChars(d,s),!(d-u<i)&&(d=e.skipSpaces(d),!(d<p)))){h=!0;break}return i=e.sCount[t],e.line=l+(h?1:0),c=e.push("fence","code",0),c.info=a,c.content=e.getLines(t+1,l,i,!0),c.markup=f,c.map=[t,e.line],!0}});var Ol=re((Yv,Rl)=>{"use strict";var Fl=_e().isSpace;Rl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M,A,O,k,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=d=e.sCount[t]+1,e.src.charCodeAt(I)===32?(I++,l++,d++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[t]+d)%4===3?(I++,l++,d++,s=!1):s=!0):S=!1,p=[e.bMarks[t]],e.bMarks[t]=I;I<P&&(i=e.src.charCodeAt(I),Fl(i));){i===9?d+=4-(d+e.bsCount[t]+(s?1:0))%4:d++;I++}for(m=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(S?1:0),c=I>=P,x=[e.sCount[t]],e.sCount[t]=d-l,C=[e.tShift[t]],e.tShift[t]=I-e.bMarks[t],A=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",h=t+1;h<n&&(k=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&&!k){for(l=d=e.sCount[h]+1,e.src.charCodeAt(I)===32?(I++,l++,d++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[h]+d)%4===3?(I++,l++,d++,s=!1):s=!0):S=!1,p.push(e.bMarks[h]),e.bMarks[h]=I;I<P&&(i=e.src.charCodeAt(I),Fl(i));){i===9?d+=4-(d+e.bsCount[h]+(s?1:0))%4:d++;I++}c=I>=P,m.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(S?1:0),x.push(e.sCount[h]),e.sCount[h]=d-l,C.push(e.tShift[h]),e.tShift[h]=I-e.bMarks[h];continue}if(c)break;for(M=!1,a=0,u=A.length;a<u;a++)if(A[a](e,h,n,!0)){M=!0;break}if(M){e.lineMax=h,e.blkIndent!==0&&(p.push(e.bMarks[h]),m.push(e.bsCount[h]),C.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}p.push(e.bMarks[h]),m.push(e.bsCount[h]),C.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]=-1}for(v=e.blkIndent,e.blkIndent=0,O=e.push("blockquote_open","blockquote",1),O.markup=">",O.map=f=[t,0],e.md.block.tokenize(e,t,h),O=e.push("blockquote_close","blockquote",-1),O.markup=">",e.lineMax=D,e.parentType=b,f[1]=e.line,a=0;a<C.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=C[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=m[a];return e.blkIndent=v,!0}});var Ml=re((Kv,Pl)=>{"use strict";var wh=_e().isSpace;Pl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u++),s!==42&&s!==45&&s!==95))return!1;for(i=1;u<c;){if(a=e.src.charCodeAt(u++),a!==s&&!wh(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 Ul=re((Xv,$l)=>{"use strict";var Bl=_e().isSpace;function _l(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),!Bl(s))?-1:n}function Nl(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),!Bl(t))?-1:o}function Eh(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)}$l.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M,A,O,k,D,I,P,N,B,H,Z,W,te=!1,ne=!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&&(te=!0),(P=Nl(e,t))>=0){if(f=!0,B=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(B,P-1)),te&&b!==1)return!1}else if((P=_l(e,t))>=0)f=!1;else return!1;if(te&&e.skipSpaces(P)>=e.eMarks[t])return!1;if(v=e.src.charCodeAt(P-1),o)return!0;for(m=e.tokens.length,f?(W=e.push("ordered_list_open","ol",1),b!==1&&(W.attrs=[["start",b]])):W=e.push("bullet_list_open","ul",1),W.map=p=[t,0],W.markup=String.fromCharCode(v),C=t,N=!1,Z=e.md.block.ruler.getRules("list"),A=e.parentType,e.parentType="list";C<n;){for(I=P,x=e.eMarks[C],c=S=e.sCount[C]+P-(e.bMarks[t]+e.tShift[t]);I<x;){if(s=e.src.charCodeAt(I),s===9)S+=4-(S+e.bsCount[C])%4;else if(s===32)S++;else break;I++}if(i=I,i>=x?u=1:u=S-c,u>4&&(u=1),l=c+u,W=e.push("list_item_open","li",1),W.markup=String.fromCharCode(v),W.map=h=[t,0],f&&(W.info=e.src.slice(B,P-1)),D=e.tight,k=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]=S,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||N)&&(ne=!1),N=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=M,e.tShift[t]=k,e.sCount[t]=O,e.tight=D,W=e.push("list_item_close","li",-1),W.markup=String.fromCharCode(v),C=t=e.line,h[1]=C,i=e.bMarks[t],C>=n||e.sCount[C]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(H=!1,a=0,d=Z.length;a<d;a++)if(Z[a](e,C,n,!0)){H=!0;break}if(H)break;if(f){if(P=Nl(e,C),P<0)break;B=e.bMarks[C]+e.tShift[C]}else if(P=_l(e,C),P<0)break;if(v!==e.src.charCodeAt(P-1))break}return f?W=e.push("ordered_list_close","ol",-1):W=e.push("bullet_list_close","ul",-1),W.markup=String.fromCharCode(v),p[1]=C,e.line=C,e.parentType=A,ne&&Eh(e,m),!0}});var jl=re((Zv,zl)=>{"use strict";var Sh=_e().normalizeReference,Tn=_e().isSpace;zl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,h,d,p,m,v,b,x,C,S,M=0,A=e.bMarks[t]+e.tShift[t],O=e.eMarks[t],k=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(A)!==91)return!1;for(;++A<O;)if(e.src.charCodeAt(A)===93&&e.src.charCodeAt(A-1)!==92){if(A+1===O||e.src.charCodeAt(A+1)!==58)return!1;break}for(l=e.lineMax,C=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";k<l&&!e.isEmpty(k);k++)if(!(e.sCount[k]-e.blkIndent>3)&&!(e.sCount[k]<0)){for(x=!1,c=0,f=C.length;c<f;c++)if(C[c](e,k,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,k,e.blkIndent,!1).trim(),O=b.length,A=1;A<O;A++){if(s=b.charCodeAt(A),s===91)return!1;if(s===93){d=A;break}else s===10?M++:s===92&&(A++,A<O&&b.charCodeAt(A)===10&&M++)}if(d<0||b.charCodeAt(d+1)!==58)return!1;for(A=d+2;A<O;A++)if(s=b.charCodeAt(A),s===10)M++;else if(!Tn(s))break;if(m=e.md.helpers.parseLinkDestination(b,A,O),!m.ok||(u=e.md.normalizeLink(m.str),!e.md.validateLink(u)))return!1;for(A=m.pos,M+=m.lines,i=A,a=M,v=A;A<O;A++)if(s=b.charCodeAt(A),s===10)M++;else if(!Tn(s))break;for(m=e.md.helpers.parseLinkTitle(b,A,O),A<O&&v!==A&&m.ok?(S=m.str,A=m.pos,M+=m.lines):(S="",A=i,M=a);A<O&&(s=b.charCodeAt(A),!!Tn(s));)A++;if(A<O&&b.charCodeAt(A)!==10&&S)for(S="",A=i,M=a;A<O&&(s=b.charCodeAt(A),!!Tn(s));)A++;return A<O&&b.charCodeAt(A)!==10||(h=Sh(b.slice(1,d)),!h)?!1:(o||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[h]>"u"&&(e.env.references[h]={title:S,href:u}),e.parentType=p,e.line=t+M+1),!0)}});var ql=re((Qv,Hl)=>{"use strict";Hl.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 Gi=re((Jv,Vi)=>{"use strict";var Ch="[a-zA-Z_:][a-zA-Z0-9:._-]*",Ah="[^\"'=<>`\\x00-\\x20]+",kh="'[^']*'",Th='"[^"]*"',Ih="(?:"+Ah+"|"+kh+"|"+Th+")",Dh="(?:\\s+"+Ch+"(?:\\s*=\\s*"+Ih+")?)",Vl="<[A-Za-z][A-Za-z0-9\\-]*"+Dh+"*\\s*\\/?>",Gl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Lh="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Fh="<[?][\\s\\S]*?[?]>",Rh="<![A-Z]+\\s+[^>]*>",Oh="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Ph=new RegExp("^(?:"+Vl+"|"+Gl+"|"+Lh+"|"+Fh+"|"+Rh+"|"+Oh+")"),Mh=new RegExp("^(?:"+Vl+"|"+Gl+")");Vi.exports.HTML_TAG_RE=Ph;Vi.exports.HTML_OPEN_CLOSE_TAG_RE=Mh});var Yl=re((ey,Wl)=>{"use strict";var _h=ql(),Nh=Gi().HTML_OPEN_CLOSE_TAG_RE,br=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+_h.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(Nh.source+"\\s*$"),/^$/,!1]];Wl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(u)!==60)return!1;for(l=e.src.slice(u,c),s=0;s<br.length&&!br[s][0].test(l);s++);if(s===br.length)return!1;if(o)return br[s][2];if(i=t+1,!br[s][1].test(l)){for(;i<n&&!(e.sCount[i]<e.blkIndent);i++)if(u=e.bMarks[i]+e.tShift[i],c=e.eMarks[i],l=e.src.slice(u,c),br[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 Zl=re((ty,Xl)=>{"use strict";var Kl=_e().isSpace;Xl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u),s!==35||u>=c))return!1;for(i=1,s=e.src.charCodeAt(++u);s===35&&u<c&&i<=6;)i++,s=e.src.charCodeAt(++u);return i>6||u<c&&!Kl(s)?!1:(o||(c=e.skipSpacesBack(c,u),a=e.skipCharsBack(c,35,u),a>u&&Kl(e.src.charCodeAt(a-1))&&(c=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(u,c).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(i),-1),l.markup="########".slice(0,i)),!0)}});var Jl=re((ry,Ql)=>{"use strict";Ql.exports=function(e,t,n){var o,s,i,a,l,u,c,f,h,d=t+1,p,m=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";d<n&&!e.isEmpty(d);d++)if(!(e.sCount[d]-e.blkIndent>3)){if(e.sCount[d]>=e.blkIndent&&(u=e.bMarks[d]+e.tShift[d],c=e.eMarks[d],u<c&&(h=e.src.charCodeAt(u),(h===45||h===61)&&(u=e.skipChars(u,h),u=e.skipSpaces(u),u>=c)))){f=h===61?1:2;break}if(!(e.sCount[d]<0)){for(s=!1,i=0,a=m.length;i<a;i++)if(m[i](e,d,n,!0)){s=!0;break}if(s)break}}return f?(o=e.getLines(t,d,e.blkIndent,!1).trim(),e.line=d+1,l=e.push("heading_open","h"+String(f),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(f),-1),l.markup=String.fromCharCode(h),e.parentType=p,!0):!1}});var tu=re((ny,eu)=>{"use strict";eu.exports=function(e,t){var n,o,s,i,a,l,u=t+1,c=e.md.block.ruler.getRules("paragraph"),f=e.lineMax;for(l=e.parentType,e.parentType="paragraph";u<f&&!e.isEmpty(u);u++)if(!(e.sCount[u]-e.blkIndent>3)&&!(e.sCount[u]<0)){for(o=!1,s=0,i=c.length;s<i;s++)if(c[s](e,u,f,!0)){o=!0;break}if(o)break}return n=e.getLines(t,u,e.blkIndent,!1).trim(),e.line=u,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 iu=re((iy,nu)=>{"use strict";var ru=kn(),In=_e().isSpace;function Pt(r,e,t,n){var o,s,i,a,l,u,c,f;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,f=!1,i=a=u=c=0,l=s.length;a<l;a++){if(o=s.charCodeAt(a),!f)if(In(o)){u++,o===9?c+=4-c%4:c++;continue}else f=!0;(o===10||a===l-1)&&(o!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(u),this.sCount.push(c),this.bsCount.push(0),f=!1,u=0,c=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}Pt.prototype.push=function(r,e,t){var n=new ru(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};Pt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Pt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Pt.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!In(t));e++);return e};Pt.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!In(this.src.charCodeAt(--e)))return e+1;return e};Pt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};Pt.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};Pt.prototype.getLines=function(e,t,n,o){var s,i,a,l,u,c,f,h=e;if(e>=t)return"";for(c=new Array(t-e),s=0;h<t;h++,s++){for(i=0,f=l=this.bMarks[h],h+1<t||o?u=this.eMarks[h]+1:u=this.eMarks[h];l<u&&i<n;){if(a=this.src.charCodeAt(l),In(a))a===9?i+=4-(i+this.bsCount[h])%4:i++;else if(l-f<this.tShift[h])i++;else break;l++}i>n?c[s]=new Array(i-n+1).join(" ")+this.src.slice(l,u):c[s]=this.src.slice(l,u)}return c.join("")};Pt.prototype.Token=ru;nu.exports=Pt});var su=re((oy,ou)=>{"use strict";var Bh=Cn(),Dn=[["table",kl(),["paragraph","reference"]],["code",Il()],["fence",Ll(),["paragraph","reference","blockquote","list"]],["blockquote",Ol(),["paragraph","reference","blockquote","list"]],["hr",Ml(),["paragraph","reference","blockquote","list"]],["list",Ul(),["paragraph","reference","blockquote"]],["reference",jl()],["html_block",Yl(),["paragraph","reference","blockquote"]],["heading",Zl(),["paragraph","reference","blockquote"]],["lheading",Jl()],["paragraph",tu()]];function Ln(){this.ruler=new Bh;for(var r=0;r<Dn.length;r++)this.ruler.push(Dn[r][0],Dn[r][1],{alt:(Dn[r][2]||[]).slice()})}Ln.prototype.tokenize=function(r,e,t){for(var n,o,s=this.ruler.getRules(""),i=s.length,a=e,l=!1,u=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=u){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)}};Ln.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))};Ln.prototype.State=iu();ou.exports=Ln});var lu=re((sy,au)=>{"use strict";function $h(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}}au.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!$h(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var cu=re((ay,uu)=>{"use strict";var Uh=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;uu.exports=function(e,t){var n,o,s,i,a,l,u,c;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(Uh),!s)||(i=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-i.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),u=e.md.normalizeLink(l),!e.md.validateLink(u))?!1:(t||(e.pending=e.pending.slice(0,-i.length),c=e.push("link_open","a",1),c.attrs=[["href",u]],c.markup="linkify",c.info="auto",c=e.push("text","",0),c.content=e.md.normalizeLinkText(l),c=e.push("link_close","a",-1),c.markup="linkify",c.info="auto"),e.pos+=l.length-i.length,!0)}});var fu=re((ly,du)=>{"use strict";var zh=_e().isSpace;du.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&&zh(e.src.charCodeAt(i));)i++;return e.pos=i,!0}});var pu=re((uy,hu)=>{"use strict";var jh=_e().isSpace,Yi=[];for(Wi=0;Wi<256;Wi++)Yi.push(0);var Wi;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){Yi[r.charCodeAt(0)]=1});hu.exports=function(e,t){var n,o,s,i,a,l=e.pos,u=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=u))return!1;if(n=e.src.charCodeAt(l),n===10){for(t||e.push("hardbreak","br",0),l++;l<u&&(n=e.src.charCodeAt(l),!!jh(n));)l++;return e.pos=l,!0}return i=e.src[l],n>=55296&&n<=56319&&l+1<u&&(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&&Yi[n]!==0?a.content=i:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var gu=re((cy,mu)=>{"use strict";mu.exports=function(e,t){var n,o,s,i,a,l,u,c,f=e.pos,h=e.src.charCodeAt(f);if(h!==96)return!1;for(n=f,f++,o=e.posMax;f<o&&e.src.charCodeAt(f)===96;)f++;if(s=e.src.slice(n,f),u=s.length,e.backticksScanned&&(e.backticks[u]||0)<=n)return t||(e.pending+=s),e.pos+=u,!0;for(a=l=f;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<o&&e.src.charCodeAt(l)===96;)l++;if(c=l-a,c===u)return t||(i=e.push("code_inline","code",0),i.markup=s,i.content=e.src.slice(f,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[c]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=u,!0}});var Xi=re((dy,Ki)=>{"use strict";Ki.exports.tokenize=function(e,t){var n,o,s,i,a,l=e.pos,u=e.src.charCodeAt(l);if(t||u!==126||(o=e.scanDelims(e.pos,!0),i=o.length,a=String.fromCharCode(u),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:u,length:0,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function vu(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)}}Ki.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(vu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&vu(e,n[t].delimiters)}});var Qi=re((fy,Zi)=>{"use strict";Zi.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 yu(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--))}Zi.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(yu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&yu(e,n[t].delimiters)}});var xu=re((hy,bu)=>{"use strict";var Hh=_e().normalizeReference,Ji=_e().isSpace;bu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,h="",d="",p=e.pos,m=e.posMax,v=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<m&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(l>=m)return!1;if(v=l,u=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),u.ok){for(h=e.md.normalizeLink(u.str),e.md.validateLink(h)?l=u.pos:h="",v=l;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(u=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<m&&v!==l&&u.ok)for(d=u.str,l=u.pos;l<m&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);}(l>=m||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<m&&e.src.charCodeAt(l)===91?(v=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(v,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),c=e.env.references[Hh(s)],!c)return e.pos=p,!1;h=c.href,d=c.title}return t||(e.pos=a,e.posMax=i,f=e.push("link_open","a",1),f.attrs=n=[["href",h]],d&&n.push(["title",d]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,f=e.push("link_close","a",-1)),e.pos=l,e.posMax=m,!0}});var Eu=re((py,wu)=>{"use strict";var qh=_e().normalizeReference,eo=_e().isSpace;wu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,h,d,p,m,v="",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(u=a+1,u<x&&e.src.charCodeAt(u)===40){for(u++;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(u>=x)return!1;for(m=u,f=e.md.helpers.parseLinkDestination(e.src,u,e.posMax),f.ok&&(v=e.md.normalizeLink(f.str),e.md.validateLink(v)?u=f.pos:v=""),m=u;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(f=e.md.helpers.parseLinkTitle(e.src,u,e.posMax),u<x&&m!==u&&f.ok)for(h=f.str,u=f.pos;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);else h="";if(u>=x||e.src.charCodeAt(u)!==41)return e.pos=b,!1;u++}else{if(typeof e.env.references>"u")return!1;if(u<x&&e.src.charCodeAt(u)===91?(m=u+1,u=e.md.helpers.parseLinkLabel(e,u),u>=0?i=e.src.slice(m,u++):u=a+1):u=a+1,i||(i=e.src.slice(l,a)),c=e.env.references[qh(i)],!c)return e.pos=b,!1;v=c.href,h=c.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),d=e.push("image","img",0),d.attrs=n=[["src",v],["alt",""]],d.children=p,d.content=s,h&&n.push(["title",h])),e.pos=u,e.posMax=x,!0}});var Cu=re((my,Su)=>{"use strict";var Vh=/^([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])?)*)$/,Gh=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Su.exports=function(e,t){var n,o,s,i,a,l,u=e.pos;if(e.src.charCodeAt(u)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++u>=l||(i=e.src.charCodeAt(u),i===60))return!1;if(i===62)break}return n=e.src.slice(a+1,u),Gh.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):Vh.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 ku=re((gy,Au)=>{"use strict";var Wh=Gi().HTML_TAG_RE;function Yh(r){return/^<a[>\s]/i.test(r)}function Kh(r){return/^<\/a\s*>/i.test(r)}function Xh(r){var e=r|32;return e>=97&&e<=122}Au.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&&!Xh(n))||(o=e.src.slice(a).match(Wh),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length),Yh(i.content)&&e.linkLevel++,Kh(i.content)&&e.linkLevel--),e.pos+=o[0].length,!0)}});var Lu=re((vy,Du)=>{"use strict";var Tu=_i(),Zh=_e().has,Qh=_e().isValidEntityCode,Iu=_e().fromCodePoint,Jh=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,ep=/^&([a-z][a-z0-9]{1,31});/i;Du.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(Jh),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=Qh(o)?Iu(o):Iu(65533),i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(ep),s&&Zh(Tu,s[1]))return t||(i=e.push("text_special","",0),i.content=Tu[s[1]],i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0;return!1}});var Ou=re((yy,Ru)=>{"use strict";function Fu(r,e){var t,n,o,s,i,a,l,u,c={},f=e.length;if(!!f){var h=0,d=-2,p=[];for(t=0;t<f;t++)if(o=e[t],p.push(0),(e[h].marker!==o.marker||d!==o.token-1)&&(h=t),d=o.token,o.length=o.length||0,!!o.close){for(c.hasOwnProperty(o.marker)||(c[o.marker]=[-1,-1,-1,-1,-1,-1]),i=c[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)){u=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+u,p[n]=u,o.open=!1,s.end=t,s.close=!1,a=-1,d=-2;break}a!==-1&&(c[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Ru.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(Fu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&Fu(e,n[t].delimiters)}});var Mu=re((by,Pu)=>{"use strict";Pu.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 Uu=re((xy,$u)=>{"use strict";var to=kn(),_u=_e().isWhiteSpace,Nu=_e().isPunctChar,Bu=_e().isMdAsciiPunct;function Ur(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}Ur.prototype.pushPending=function(){var r=new to("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};Ur.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new to(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};Ur.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,u,c,f,h=!0,d=!0,p=this.posMax,m=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===m;)t++;return s=t-r,o=t<p?this.src.charCodeAt(t):32,u=Bu(n)||Nu(String.fromCharCode(n)),f=Bu(o)||Nu(String.fromCharCode(o)),l=_u(n),c=_u(o),c?h=!1:f&&(l||u||(h=!1)),l?d=!1:u&&(c||f||(d=!1)),e?(i=h,a=d):(i=h&&(!d||u),a=d&&(!h||f)),{can_open:i,can_close:a,length:s}};Ur.prototype.Token=to;$u.exports=Ur});var Hu=re((wy,ju)=>{"use strict";var zu=Cn(),ro=[["text",lu()],["linkify",cu()],["newline",fu()],["escape",pu()],["backticks",gu()],["strikethrough",Xi().tokenize],["emphasis",Qi().tokenize],["link",xu()],["image",Eu()],["autolink",Cu()],["html_inline",ku()],["entity",Lu()]],no=[["balance_pairs",Ou()],["strikethrough",Xi().postProcess],["emphasis",Qi().postProcess],["fragments_join",Mu()]];function zr(){var r;for(this.ruler=new zu,r=0;r<ro.length;r++)this.ruler.push(ro[r][0],ro[r][1]);for(this.ruler2=new zu,r=0;r<no.length;r++)this.ruler2.push(no[r][0],no[r][1])}zr.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};zr.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()};zr.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)};zr.prototype.State=Uu();ju.exports=zr});var Vu=re((Ey,qu)=>{"use strict";qu.exports=function(r){var e={};r=r||{},e.src_Any=Bi().source,e.src_Cc=$i().source,e.src_Z=Ui().source,e.src_P=bn().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 Xu=re((Sy,Ku)=>{"use strict";function io(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 Rn(r){return Object.prototype.toString.call(r)}function tp(r){return Rn(r)==="[object String]"}function rp(r){return Rn(r)==="[object Object]"}function np(r){return Rn(r)==="[object RegExp]"}function Gu(r){return Rn(r)==="[object Function]"}function ip(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var Yu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function op(r){return Object.keys(r||{}).reduce(function(e,t){return e||Yu.hasOwnProperty(t)},!1)}var sp={"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}}},ap="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]",lp="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function up(r){r.__index__=-1,r.__text_cache__=""}function cp(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function Wu(){return function(r,e){e.normalize(r)}}function Fn(r){var e=r.re=Vu()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(ap),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 u={validate:null,link:null};if(r.__compiled__[a]=u,rp(l)){np(l.validate)?u.validate=cp(l.validate):Gu(l.validate)?u.validate=l.validate:s(a,l),Gu(l.normalize)?u.normalize=l.normalize:l.normalize?s(a,l):u.normalize=Wu();return}if(tp(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:Wu()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(ip).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"),up(r)}function dp(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 oo(r,e){var t=new dp(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function bt(r,e){if(!(this instanceof bt))return new bt(r,e);e||op(r)&&(e=r,r={}),this.__opts__=io({},Yu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=io({},sp,r),this.__compiled__={},this.__tlds__=lp,this.__tlds_replaced__=!1,this.re={},Fn(this)}bt.prototype.add=function(e,t){return this.__schemas__[e]=t,Fn(this),this};bt.prototype.set=function(e){return this.__opts__=io(this.__opts__,e),this};bt.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,o,s,i,a,l,u,c;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:"]&&(u=e.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<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:"]&&(c=e.indexOf("@"),c>=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};bt.prototype.pretest=function(e){return this.re.pretest.test(e)};bt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};bt.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(oo(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(oo(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};bt.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,oo(this,0)):null};bt.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(),Fn(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Fn(this),this)};bt.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};bt.prototype.onCompile=function(){};Ku.exports=bt});var ic={};_d(ic,{decode:()=>uo,default:()=>bp,encode:()=>co,toASCII:()=>nc,toUnicode:()=>rc,ucs2decode:()=>lo,ucs2encode:()=>ec});function rr(r){throw new RangeError(mp[r])}function gp(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function Ju(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(pp,".");let o=r.split("."),s=gp(o,e).join(".");return n+s}function lo(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 Qu,fp,hp,pp,mp,so,Mt,ao,ec,vp,Zu,tc,uo,co,rc,nc,yp,bp,oc=Md(()=>{"use strict";Qu="-",fp=/^xn--/,hp=/[^\0-\x7E]/,pp=/[\x2E\u3002\uFF0E\uFF61]/g,mp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},so=36-1,Mt=Math.floor,ao=String.fromCharCode;ec=r=>String.fromCodePoint(...r),vp=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36},Zu=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},tc=function(r,e,t){let n=0;for(r=t?Mt(r/700):r>>1,r+=Mt(r/e);r>so*26>>1;n+=36)r=Mt(r/so);return Mt(n+(so+1)*r/(r+38))},uo=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(Qu);i<0&&(i=0);for(let a=0;a<i;++a)r.charCodeAt(a)>=128&&rr("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a<t;){let l=n;for(let c=1,f=36;;f+=36){a>=t&&rr("invalid-input");let h=vp(r.charCodeAt(a++));(h>=36||h>Mt((2147483647-n)/c))&&rr("overflow"),n+=h*c;let d=f<=s?1:f>=s+26?26:f-s;if(h<d)break;let p=36-d;c>Mt(2147483647/p)&&rr("overflow"),c*=p}let u=e.length+1;s=tc(n-l,u,l==0),Mt(n/u)>2147483647-o&&rr("overflow"),o+=Mt(n/u),n%=u,e.splice(n++,0,o)}return String.fromCodePoint(...e)},co=function(r){let e=[];r=lo(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(ao(l));let i=e.length,a=i;for(i&&e.push(Qu);a<t;){let l=2147483647;for(let c of r)c>=n&&c<l&&(l=c);let u=a+1;l-n>Mt((2147483647-o)/u)&&rr("overflow"),o+=(l-n)*u,n=l;for(let c of r)if(c<n&&++o>2147483647&&rr("overflow"),c==n){let f=o;for(let h=36;;h+=36){let d=h<=s?1:h>=s+26?26:h-s;if(f<d)break;let p=f-d,m=36-d;e.push(ao(Zu(d+p%m,0))),f=Mt(p/m)}e.push(ao(Zu(f,0))),s=tc(o,u,a==i),o=0,++a}++o,++n}return e.join("")},rc=function(r){return Ju(r,function(e){return fp.test(e)?uo(e.slice(4).toLowerCase()):e})},nc=function(r){return Ju(r,function(e){return hp.test(e)?"xn--"+co(e):e})},yp={version:"2.1.0",ucs2:{decode:lo,encode:ec},decode:uo,encode:co,toASCII:nc,toUnicode:rc},bp=yp});var ac=re((Cy,sc)=>{"use strict";sc.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 uc=re((Ay,lc)=>{"use strict";lc.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 dc=re((ky,cc)=>{"use strict";cc.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 mc=re((Ty,pc)=>{"use strict";var jr=_e(),xp=Ya(),wp=Xa(),Ep=Sl(),Sp=su(),Cp=Hu(),Ap=Xu(),nr=Ni(),fc=(oc(),Nd(ic)),kp={default:ac(),zero:uc(),commonmark:dc()},Tp=/^(vbscript|javascript|file|data):/,Ip=/^data:image\/(gif|png|jpeg|webp);/;function Dp(r){var e=r.trim().toLowerCase();return Tp.test(e)?!!Ip.test(e):!0}var hc=["http:","https:","mailto:"];function Lp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toASCII(e.hostname)}catch{}return nr.encode(nr.format(e))}function Fp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toUnicode(e.hostname)}catch{}return nr.decode(nr.format(e),nr.decode.defaultChars+"%")}function Ct(r,e){if(!(this instanceof Ct))return new Ct(r,e);e||jr.isString(r)||(e=r||{},r="default"),this.inline=new Cp,this.block=new Sp,this.core=new Ep,this.renderer=new wp,this.linkify=new Ap,this.validateLink=Dp,this.normalizeLink=Lp,this.normalizeLinkText=Fp,this.utils=jr,this.helpers=jr.assign({},xp),this.options={},this.configure(r),e&&this.set(e)}Ct.prototype.set=function(r){return jr.assign(this.options,r),this};Ct.prototype.configure=function(r){var e=this,t;if(jr.isString(r)&&(t=r,r=kp[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};Ct.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};Ct.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};Ct.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};Ct.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};Ct.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};Ct.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};Ct.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};pc.exports=Ct});var vc=re((Iy,gc)=>{"use strict";gc.exports=mc()});var Ec=re((Dy,wc)=>{var fo=!0,bc=!1,xc=!1;wc.exports=function(r,e){e&&(fo=!e.enabled,bc=!!e.label,xc=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o<n.length;o++)Op(n,o)&&(Pp(n[o],t.Token),yc(n[o-2],"class","task-list-item"+(fo?"":" enabled")),yc(n[Rp(n,o-2)],"class","contains-task-list"))})};function yc(r,e,t){var n=r.attrIndex(e),o=[e,t];n<0?r.attrPush(o):r.attrs[n]=o}function Rp(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 Op(r,e){return $p(r[e])&&Up(r[e-1])&&zp(r[e-2])&&jp(r[e])}function Pp(r,e){if(r.children.unshift(Mp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),bc)if(xc){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(Bp(r.content,t,e))}else r.children.unshift(_p(e)),r.children.push(Np(e))}function Mp(r,e){var t=new e("html_inline","",0),n=fo?' 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 _p(r){var e=new r("html_inline","",0);return e.content="<label>",e}function Np(r){var e=new r("html_inline","",0);return e.content="</label>",e}function Bp(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 $p(r){return r.type==="inline"}function Up(r){return r.type==="paragraph_open"}function zp(r){return r.type==="list_item_open"}function jp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var _c=re((Gr,Io)=>{(function(r,e){typeof Gr=="object"&&typeof Io=="object"?Io.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Gr=="object"?Gr.ClipboardJS=e():r.ClipboardJS=e()})(Gr,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return A}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),u=s.n(l);function c(O){try{return document.execCommand(O)}catch{return}}var f=function(O){return O=u()(O),c("cut"),O};function h(P,k){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 k.container.appendChild(P),k=u()(P),c("copy"),P.remove(),k}var d=function(O){var k=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof O=="string"?D=h(O,k):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O?.type)?D=h(O.value,k):(D=u()(O),c("copy")),D};function p(O){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k})(O)}var m=function(){var I=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=I.action,O=D===void 0?"copy":D,k=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?d(I,{container:k}):D?O==="cut"?f(D):d(D,{container:k}):void 0};function v(O){return(v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k})(O)}function b(O,k){for(var D=0;D<k.length;D++){var I=k[D];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(O,I.key,I)}}function x(O,k){return(x=Object.setPrototypeOf||function(D,I){return D.__proto__=I,D})(O,k)}function C(O){var k=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=S(O);return D=k?(D=S(this).constructor,Reflect.construct(I,arguments,D)):I.apply(this,arguments),I=this,!(D=D)||v(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 S(O){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(k){return k.__proto__||Object.getPrototypeOf(k)})(O)}function M(O,k){if(O="data-clipboard-".concat(O),k.hasAttribute(O))return k.getAttribute(O)}var A=function(){(function(N,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function");N.prototype=Object.create(B&&B.prototype,{constructor:{value:N,writable:!0,configurable:!0}}),B&&x(N,B)})(P,i());var O,k,D,I=C(P);function P(N,B){var H;return function(Z){if(!(Z instanceof P))throw new TypeError("Cannot call a class as a function")}(this),(H=I.call(this)).resolveOptions(B),H.listenClick(N),H}return O=P,D=[{key:"copy",value:function(N){var B=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return d(N,B)}},{key:"cut",value:function(N){return f(N)}},{key:"isSupported",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],N=typeof N=="string"?[N]:N,B=!!document.queryCommandSupported;return N.forEach(function(H){B=B&&!!document.queryCommandSupported(H)}),B}}],(k=[{key:"resolveOptions",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=v(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var B=this;this.listener=a()(N,"click",function(H){return B.onClick(H)})}},{key:"onClick",value:function(Z){var B=Z.delegateTarget||Z.currentTarget,H=this.action(B)||"copy",Z=m({action:H,container:this.container,target:this.target(B),text:this.text(B)});this.emit(Z?"success":"error",{action:H,text:Z,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return M("action",N)}},{key:"defaultTarget",value:function(N){if(N=M("target",N),N)return document.querySelector(N)}},{key:"defaultText",value:function(N){return M("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(O.prototype,k),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,u,c,f,h){var d=function(p,m,v,b){return function(x){x.delegateTarget=i(x.target,m),x.delegateTarget&&b.call(p,x)}}.apply(this,arguments);return l.addEventListener(c,d,h),{destroy:function(){l.removeEventListener(c,d,h)}}}n.exports=function(l,u,c,f,h){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof c=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(d){return a(d,u,c,f,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,u,c){if(!l&&!u&&!c)throw new Error("Missing required arguments");if(!i.string(u))throw new TypeError("Second argument must be a String");if(!i.fn(c))throw new TypeError("Third argument must be a Function");if(i.node(l))return m=u,v=c,(p=l).addEventListener(m,v),{destroy:function(){p.removeEventListener(m,v)}};if(i.nodeList(l))return f=l,h=u,d=c,Array.prototype.forEach.call(f,function(b){b.addEventListener(h,d)}),{destroy:function(){Array.prototype.forEach.call(f,function(b){b.removeEventListener(h,d)})}};if(i.string(l))return l=l,u=u,c=c,a(document.body,l,u,c);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var f,h,d,p,m,v}},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 u(){l.off(s,u),i.apply(a,arguments)}return u._=i,this.on(s,u,a)},emit:function(s){for(var i=[].slice.call(arguments,1),a=((this.e||(this.e={}))[s]||[]).slice(),l=0,u=a.length;l<u;l++)a[l].fn.apply(a[l].ctx,i);return this},off:function(s,i){var a=this.e||(this.e={}),l=a[s],u=[];if(l&&i)for(var c=0,f=l.length;c<f;c++)l[c].fn!==i&&l[c].fn._!==i&&u.push(l[c]);return u.length?a[s]=u: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 Sr={},Bd=[];function Kr(r,e){if(Bd.push({name:r,data:e}),typeof Sr[r]>"u")return this;let t=Sr[r];for(let n=0;n<t.length;n++)t[n](e)}function $d(r,e){typeof Sr[r]>"u"&&(Sr[r]=[]),Sr[r].push(e)}function Ud(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function zd(r){if(!!r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
+`);Kr("error",e)}}var Jo={emit:Kr,emitPublic:Ud,listen:$d,success:r=>Kr("success",r),error:r=>Kr("error",r),showValidationErrors:zd};async function jd(r,e={}){return es(r,{method:"GET",params:e})}async function Hd(r,e=null){return Xr("POST",r,e)}async function qd(r,e=null){return Xr("PUT",r,e)}async function Vd(r,e=null){return Xr("PATCH",r,e)}async function Gd(r,e=null){return Xr("DELETE",r,e)}async function Xr(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"),es(e,n)}async function es(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),s={data:await Wd(n),headers:n.headers,redirected:n.redirected,status:n.status,statusText:n.statusText,url:n.url,original:n};if(!n.ok)throw s;return s}async function Wd(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 ts={get:jd,post:Hd,put:qd,patch:Vd,delete:Gd};var Un=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 u=l.match(s);if(u!==null&&Number(u[1])===t){a=l.replace(s,"").trim();break}let c=l.match(i);if(c!==null&&Number(c[1])<=t&&(c[2]==="*"||Number(c[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}},rs=Un;function Zr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Qr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Be(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 Jr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function qe(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function ns(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 Cr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function is(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ar(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 kr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=document.getElementById("custom-styles").getAttribute("data-color-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 ss(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function as(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var zn=class{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)),qe(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=as(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},ls=zn;var jn=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Be(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})}},us=jn;var Hn=class{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}Jr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Be(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}},cs=Hn;var qn=class{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(),this.mainTabs.components.tabs.show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.list.innerHTML=e.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"),Cr(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")}},ds=qn;var Vn=class{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")}},fs=Vn;var Gn={},Wn=class{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)),qe(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),qe(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),o=t[n+(e?1:-1)];o&&o.focus()}async requestSuggestions(){if(Date.now()-this.lastPopulated<50)return;let e=this.getNameFilterIfNeeded(),t=this.input.value.slice(0,3).toLowerCase(),n=await this.loadSuggestions(t,e),o=n.slice(0,6);t.length>0&&(o=n.filter(s=>s.toLowerCase().includes(t)).slice(0,6)),this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){let n={search:e,name:t},o=`${this.url}:${JSON.stringify(n)}`;if(Gn[o])return Gn[o];let s=await window.$http.get(this.url,n);return Gn[o]=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">${ss(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()}},hs=Wn;var Yn=class{constructor(e){if(this.elem=e,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.elem.style.display="none";return}this.elem.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.elem.style.display="block",this.showing=!0,setTimeout(()=>{this.elem.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.elem.style.opacity=0,this.showing=!1,setTimeout(()=>{this.elem.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))}},ps=Yn;function ms(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 Rt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ms(Object(t),!0).forEach(function(n){Yd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ms(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function on(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?on=function(e){return typeof e}:on=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(r)}function Yd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function jt(){return jt=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},jt.apply(this,arguments)}function Kd(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 Xd(r,e){if(r==null)return{};var t=Kd(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}var Zd="1.15.0";function zt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Ht=zt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Mr=zt(/Edge/i),gs=zt(/firefox/i),Lr=zt(/safari/i)&&!zt(/chrome/i)&&!zt(/android/i),Cs=zt(/iP(ad|od|hone)/i),As=zt(/chrome/i)&&zt(/android/i),ks={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!Ht&&ks)}function Le(r,e,t){r.removeEventListener(e,t,!Ht&&ks)}function cn(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 Qd(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Lt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&cn(r,e):cn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Qd(r))}return null}var vs=/\s+/g;function gt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(vs," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(vs," ")}}function ge(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=ge(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 Ts(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 Ft(){var r=document.scrollingElement;return r||document.documentElement}function tt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,u,c,f;if(r!==window&&r.parentNode&&r!==Ft()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,u=s.right,c=s.height,f=s.width):(i=0,a=0,l=window.innerHeight,u=window.innerWidth,c=window.innerHeight,f=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!Ht))do if(o&&o.getBoundingClientRect&&(ge(o,"transform")!=="none"||t&&ge(o,"position")!=="static")){var h=o.getBoundingClientRect();i-=h.top+parseInt(ge(o,"border-top-width")),a-=h.left+parseInt(ge(o,"border-left-width")),l=i+s.height,u=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var d=dr(o||r),p=d&&d.a,m=d&&d.d;d&&(i/=m,a/=p,f/=p,c/=m,l=i+c,u=a+f)}return{top:i,left:a,bottom:l,right:u,width:f,height:c}}}function ys(r,e,t){for(var n=Kt(r,!0),o=tt(r)[e];n;){var s=tt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ft())break;n=Kt(n,!1)}return!1}function fr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ve.ghost&&(n||i[s]!==ve.dragged)&&Lt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function li(r,e){for(var t=r.lastElementChild;t&&(t===ve.ghost||ge(t,"display")==="none"||e&&!cn(t,e));)t=t.previousElementSibling;return t||null}function St(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ve.clone&&(!e||cn(r,e))&&t++;return t}function bs(r){var e=0,t=0,n=Ft();if(r)do{var o=dr(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 Jd(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 Kt(r,e){if(!r||!r.getBoundingClientRect)return Ft();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ge(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 Ft();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ft()}function ef(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Kn(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 Fr;function Is(r,e){return function(){if(!Fr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Fr=setTimeout(function(){Fr=void 0},e)}}}function tf(){clearTimeout(Fr),Fr=void 0}function Ds(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Ls(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)}var yt="Sortable"+new Date().getTime();function rf(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ge(o,"display")==="none"||o===ve.ghost)){r.push({target:o,rect:tt(o)});var s=Rt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=dr(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(Jd(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,u=a.target,c=u.fromRect,f=tt(u),h=u.prevFromRect,d=u.prevToRect,p=a.rect,m=dr(u,!0);m&&(f.top-=m.f,f.left-=m.e),u.toRect=f,u.thisAnimationDuration&&Kn(h,f)&&!Kn(c,f)&&(p.top-f.top)/(p.left-f.left)===(c.top-f.top)/(c.left-f.left)&&(l=of(p,h,d,o.options)),Kn(f,c)||(u.prevFromRect=c,u.prevToRect=f,l||(l=o.options.animation),o.animate(u,p,f,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(u.animationResetTimer),u.animationResetTimer=setTimeout(function(){u.animationTime=0,u.prevFromRect=null,u.fromRect=null,u.prevToRect=null,u.thisAnimationDuration=null},l),u.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){ge(n,"transition",""),ge(n,"transform","");var a=dr(this.el),l=a&&a.a,u=a&&a.d,c=(o.left-s.left)/(l||1),f=(o.top-s.top)/(u||1);n.animatingX=!!c,n.animatingY=!!f,ge(n,"transform","translate3d("+c+"px,"+f+"px,0)"),this.forRepaintDummy=nf(n),ge(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ge(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ge(n,"transition",""),ge(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function nf(r){return r.offsetWidth}function of(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 ar=[],Xn={initializeByDefault:!0},_r={mount:function(e){for(var t in Xn)Xn.hasOwnProperty(t)&&!(t in e)&&(e[t]=Xn[t]);ar.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ar.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";ar.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Rt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Rt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){ar.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var u=new a(e,t,e.options);u.sortable=e,u.options=e.options,e[l]=u,jt(n,u.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 ar.forEach(function(o){typeof o.eventProperties=="function"&&jt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return ar.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function sf(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,u=r.newIndex,c=r.oldDraggableIndex,f=r.newDraggableIndex,h=r.originalEvent,d=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[yt],!!e){var m,v=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Ht&&!Mr?m=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(n,!0,!0)),m.to=i||t,m.from=a||t,m.item=o||t,m.clone=s,m.oldIndex=l,m.newIndex=u,m.oldDraggableIndex=c,m.newDraggableIndex=f,m.originalEvent=h,m.pullMode=d?d.lastPutMode:void 0;var x=Rt(Rt({},p),_r.getEventProperties(n,e));for(var C in x)m[C]=x[C];t&&t.dispatchEvent(m),v[b]&&v[b].call(e,m)}}var af=["evt"],ht=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Xd(n,af);_r.pluginEvent.bind(ve)(e,t,Rt({dragEl:ee,parentEl:Ze,ghostEl:we,rootEl:Ve,nextEl:er,lastDownEl:sn,cloneEl:Ye,cloneHidden:Yt,dragStarted:Tr,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:cr,oldDraggableIndex:Rr,newIndex:vt,newDraggableIndex:Wt,hideGhostForTarget:Ps,unhideGhostForTarget:Ms,cloneNowHidden:function(){Yt=!0},cloneNowShown:function(){Yt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){sf(Rt({putSortable:it,cloneEl:Ye,targetEl:ee,rootEl:Ve,oldIndex:cr,oldDraggableIndex:Rr,newIndex:vt,newDraggableIndex:Wt},r))}var ee,Ze,we,Ve,er,sn,Ye,Yt,cr,vt,Rr,Wt,en,it,ur=!1,dn=!1,fn=[],Qt,kt,Zn,Qn,xs,ws,Tr,lr,Or,Pr=!1,tn=!1,an,lt,Jn=[],ii=!1,hn=[],mn=typeof document<"u",rn=Cs,Es=Mr||Ht?"cssFloat":"float",lf=mn&&!As&&!Cs&&"draggable"in document.createElement("div"),Fs=function(){if(!!mn){if(Ht)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Rs=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=fr(e,0,t),i=fr(e,1,t),a=s&&ge(s),l=i&&ge(i),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+tt(s).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+tt(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 f=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===f)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=o&&n[Es]==="none"||i&&n[Es]==="none"&&u+c>o)?"vertical":"horizontal"},uf=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,u=n?t.width:t.height;return o===a||s===l||o+i/2===a+u/2},cf=function(e,t){var n;return fn.some(function(o){var s=o[yt].options.emptyInsertThreshold;if(!(!s||li(o))){var i=tt(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},Os=function(e){function t(s,i){return function(a,l,u,c){var f=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||f))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,u,c),i)(a,l,u,c);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||on(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},Ps=function(){!Fs&&we&&ge(we,"display","none")},Ms=function(){!Fs&&we&&ge(we,"display","")};mn&&!As&&document.addEventListener("click",function(r){if(dn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),dn=!1,!1},!0);var Jt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=cf(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[yt]._onDragOver(n)}}},df=function(e){ee&&ee.parentNode[yt]._isOutsideThisEl(e.target)};function ve(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=jt({},e),r[yt]=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 Rs(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:ve.supportPointer!==!1&&"PointerEvent"in window&&!Lr,emptyInsertThreshold:5};_r.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);Os(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:lf,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Me(r,"pointerdown",this._onTapStart):(Me(r,"mousedown",this._onTapStart),Me(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(Me(r,"dragover",this),Me(r,"dragenter",this)),fn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),jt(this,rf())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(lr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,ee):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,u=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=o.filter;if(bf(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Lr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Lt(l,o.draggable,n,!1),!(l&&l.animated)&&sn!==l)){if(cr=St(l),Rr=St(l,o.draggable),typeof c=="function"){if(c.call(this,e,l,this)){ct({sortable:t,rootEl:u,name:"filter",targetEl:l,toEl:n,fromEl:n}),ht("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(c&&(c=c.split(",").some(function(f){if(f=Lt(u,f.trim(),n,!1),f)return ct({sortable:t,rootEl:f,name:"filter",targetEl:l,fromEl:n,toEl:n}),ht("filter",t,{evt:e}),!0}),c)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Lt(u,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&&!ee&&n.parentNode===s){var u=tt(n);if(Ve=s,ee=n,Ze=ee.parentNode,er=ee.nextSibling,sn=n,en=i.group,ve.dragged=ee,Qt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},xs=Qt.clientX-u.left,ws=Qt.clientY-u.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,ee.style["will-change"]="all",l=function(){if(ht("delayEnded",o,{evt:e}),ve.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!gs&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),gt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){Ts(ee,c.trim(),ei)}),Me(a,"dragover",Jt),Me(a,"mousemove",Jt),Me(a,"touchmove",Jt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),gs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Mr||Ht))){if(ve.eventCanceled){this._onDrop();return}Me(a,"mouseup",o._disableDelayedDrag),Me(a,"touchend",o._disableDelayedDrag),Me(a,"touchcancel",o._disableDelayedDrag),Me(a,"mousemove",o._delayedDragTouchMoveHandler),Me(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&Me(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(){ee&&ei(ee),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._disableDelayedDrag),Le(e,"touchend",this._disableDelayedDrag),Le(e,"touchcancel",this._disableDelayedDrag),Le(e,"mousemove",this._delayedDragTouchMoveHandler),Le(e,"touchmove",this._delayedDragTouchMoveHandler),Le(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Me(document,"pointermove",this._onTouchMove):t?Me(document,"touchmove",this._onTouchMove):Me(document,"mousemove",this._onTouchMove):(Me(ee,"dragend",this),Me(Ve,"dragstart",this._onDragStart));try{document.selection?ln(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ur=!1,Ve&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",df);var n=this.options;!e&>(ee,n.dragClass,!1),gt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(kt){this._lastX=kt.clientX,this._lastY=kt.clientY,Ps();for(var e=document.elementFromPoint(kt.clientX,kt.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(kt.clientX,kt.clientY),e!==t);)t=e;if(ee.parentNode[yt]._isOutsideThisEl(e),t)do{if(t[yt]){var n=void 0;if(n=t[yt]._onDragOver({clientX:kt.clientX,clientY:kt.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ms()}},_onTouchMove:function(e){if(Qt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&dr(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=rn&<&&bs(lt),c=(s.clientX-Qt.clientX+o.x)/(a||1)+(u?u[0]-Jn[0]:0)/(a||1),f=(s.clientY-Qt.clientY+o.y)/(l||1)+(u?u[1]-Jn[1]:0)/(l||1);if(!ve.active&&!ur){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(we){i?(i.e+=c-(Zn||0),i.f+=f-(Qn||0)):i={a:1,b:0,c:0,d:1,e:c,f};var h="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ge(we,"webkitTransform",h),ge(we,"mozTransform",h),ge(we,"msTransform",h),ge(we,"transform",h),Zn=c,Qn=f,kt=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!we){var e=this.options.fallbackOnBody?document.body:Ve,t=tt(ee,!0,rn,!0,e),n=this.options;if(rn){for(lt=e;ge(lt,"position")==="static"&&ge(lt,"transform")==="none"&<!==document;)lt=lt.parentNode;lt!==document.body&<!==document.documentElement?(lt===document&&(lt=Ft()),t.top+=lt.scrollTop,t.left+=lt.scrollLeft):lt=Ft(),Jn=bs(lt)}we=ee.cloneNode(!0),gt(we,n.ghostClass,!1),gt(we,n.fallbackClass,!0),gt(we,n.dragClass,!0),ge(we,"transition",""),ge(we,"transform",""),ge(we,"box-sizing","border-box"),ge(we,"margin",0),ge(we,"top",t.top),ge(we,"left",t.left),ge(we,"width",t.width),ge(we,"height",t.height),ge(we,"opacity","0.8"),ge(we,"position",rn?"absolute":"fixed"),ge(we,"zIndex","100000"),ge(we,"pointerEvents","none"),ve.ghost=we,e.appendChild(we),ge(we,"transform-origin",xs/parseInt(we.style.width)*100+"% "+ws/parseInt(we.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(ht("dragStart",this,{evt:e}),ve.eventCanceled){this._onDrop();return}ht("setupClone",this),ve.eventCanceled||(Ye=Ls(ee),Ye.removeAttribute("id"),Ye.draggable=!1,Ye.style["will-change"]="",this._hideClone(),gt(Ye,this.options.chosenClass,!1),ve.clone=Ye),n.cloneId=ln(function(){ht("clone",n),!ve.eventCanceled&&(n.options.removeCloneOnHide||Ve.insertBefore(Ye,ee),n._hideClone(),ct({sortable:n,name:"clone"}))}),!t&>(ee,s.dragClass,!0),t?(dn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Le(document,"mouseup",n._onDrop),Le(document,"touchend",n._onDrop),Le(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,ee)),Me(document,"drop",n),ge(ee,"transform","translateZ(0)")),ur=!0,n._dragStartId=ln(n._dragStarted.bind(n,t,e)),Me(document,"selectstart",n),Tr=!0,Lr&&ge(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,u=ve.active,c=en===l,f=a.sort,h=it||u,d,p=this,m=!1;if(ii)return;function v(ne,be){ht(ne,p,Rt({evt:e,isOwner:c,axis:d?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:f,fromSortable:h,target:n,completed:x,onMove:function(xe,Fe){return nn(Ve,t,ee,o,xe,tt(xe),e,Fe)},changed:C},be))}function b(){v("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ne){return v("dragOverCompleted",{insertion:ne}),ne&&(c?u._hideClone():u._showClone(p),p!==h&&(gt(ee,it?it.options.ghostClass:u.options.ghostClass,!1),gt(ee,a.ghostClass,!0)),it!==p&&p!==ve.active?it=p:p===ve.active&&it&&(it=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){v("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===ee&&!ee.animated||n===t&&!n.animated)&&(lr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(ee.parentNode[yt]._isOutsideThisEl(e.target),!ne&&Jt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),m=!0}function C(){vt=St(ee),Wt=St(ee,a.draggable),ct({sortable:p,name:"change",toEl:t,newIndex:vt,newDraggableIndex:Wt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Lt(n,a.draggable,t,!0),v("dragOver"),ve.eventCanceled)return m;if(ee.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(dn=!1,u&&!a.disabled&&(c?f||(i=Ze!==Ve):it===this||(this.lastPutMode=en.checkPull(this,u,ee,e))&&l.checkPut(this,u,ee,e))){if(d=this._getDirection(e,n)==="vertical",o=tt(ee),v("dragOverValid"),ve.eventCanceled)return m;if(i)return Ze=Ve,b(),this._hideClone(),v("revert"),ve.eventCanceled||(er?Ve.insertBefore(ee,er):Ve.appendChild(ee)),x(!0);var S=li(t,a.draggable);if(!S||mf(e,d,this)&&!S.animated){if(S===ee)return x(!1);if(S&&t===e.target&&(n=S),n&&(s=tt(n)),nn(Ve,t,ee,o,n,s,e,!!n)!==!1)return b(),S&&S.nextSibling?t.insertBefore(ee,S.nextSibling):t.appendChild(ee),Ze=t,C(),x(!0)}else if(S&&pf(e,d,this)){var M=fr(t,0,a,!0);if(M===ee)return x(!1);if(n=M,s=tt(n),nn(Ve,t,ee,o,n,s,e,!1)!==!1)return b(),t.insertBefore(ee,M),Ze=t,C(),x(!0)}else if(n.parentNode===t){s=tt(n);var A=0,O,k=ee.parentNode!==t,D=!uf(ee.animated&&ee.toRect||o,n.animated&&n.toRect||s,d),I=d?"top":"left",P=ys(n,"top","top")||ys(ee,"top","top"),N=P?P.scrollTop:void 0;lr!==n&&(O=s[I],Pr=!1,tn=!D&&a.invertSwap||k),A=gf(e,n,s,d,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,tn,lr===n);var B;if(A!==0){var H=St(ee);do H-=A,B=Ze.children[H];while(B&&(ge(B,"display")==="none"||B===we))}if(A===0||B===n)return x(!1);lr=n,Or=A;var Z=n.nextElementSibling,W=!1;W=A===1;var te=nn(Ve,t,ee,o,n,s,e,W);if(te!==!1)return(te===1||te===-1)&&(W=te===1),ii=!0,setTimeout(hf,30),b(),W&&!Z?t.appendChild(ee):n.parentNode.insertBefore(ee,W?Z:n),P&&Ds(P,0,N-P.scrollTop),Ze=ee.parentNode,O!==void 0&&!tn&&(an=Math.abs(O-tt(n)[I])),C(),x(!0)}if(t.contains(ee))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Le(document,"mousemove",this._onTouchMove),Le(document,"touchmove",this._onTouchMove),Le(document,"pointermove",this._onTouchMove),Le(document,"dragover",Jt),Le(document,"mousemove",Jt),Le(document,"touchmove",Jt)},_offUpEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._onDrop),Le(e,"touchend",this._onDrop),Le(e,"pointerup",this._onDrop),Le(e,"touchcancel",this._onDrop),Le(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(vt=St(ee),Wt=St(ee,n.draggable),ht("drop",this,{evt:e}),Ze=ee&&ee.parentNode,vt=St(ee),Wt=St(ee,n.draggable),ve.eventCanceled){this._nulling();return}ur=!1,tn=!1,Pr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),oi(this.cloneId),oi(this._dragStartId),this.nativeDraggable&&(Le(document,"drop",this),Le(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Lr&&ge(document.body,"user-select",""),ge(ee,"transform",""),e&&(Tr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),we&&we.parentNode&&we.parentNode.removeChild(we),(Ve===Ze||it&&it.lastPutMode!=="clone")&&Ye&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),ee&&(this.nativeDraggable&&Le(ee,"dragend",this),ei(ee),ee.style["will-change"]="",Tr&&!ur&>(ee,it?it.options.ghostClass:this.options.ghostClass,!1),gt(ee,this.options.chosenClass,!1),ct({sortable:this,name:"unchoose",toEl:Ze,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ve!==Ze?(vt>=0&&(ct({rootEl:Ze,name:"add",toEl:Ze,fromEl:Ve,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Ze,originalEvent:e}),ct({rootEl:Ze,name:"sort",toEl:Ze,fromEl:Ve,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),it&&it.save()):vt!==cr&&vt>=0&&(ct({sortable:this,name:"update",toEl:Ze,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),ve.active&&((vt==null||vt===-1)&&(vt=cr,Wt=Rr),ct({sortable:this,name:"end",toEl:Ze,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),Ve=ee=Ze=we=er=Ye=sn=Yt=Qt=kt=Tr=vt=Wt=cr=Rr=lr=Or=it=en=ve.dragged=ve.ghost=ve.clone=ve.active=null,hn.forEach(function(e){e.checked=!0}),hn.length=Zn=Qn=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),ff(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],Lt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||yf(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Lt(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 Lt(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=_r.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&Os(n)},destroy:function(){ht("destroy",this);var e=this.el;e[yt]=null,Le(e,"mousedown",this._onTapStart),Le(e,"touchstart",this._onTapStart),Le(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Le(e,"dragover",this),Le(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),fn.splice(fn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Yt){if(ht("hideClone",this),ve.eventCanceled)return;ge(Ye,"display","none"),this.options.removeCloneOnHide&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),Yt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Yt){if(ht("showClone",this),ve.eventCanceled)return;ee.parentNode==Ve&&!this.options.group.revertClone?Ve.insertBefore(Ye,ee):er?Ve.insertBefore(Ye,er):Ve.appendChild(Ye),this.options.group.revertClone&&this.animate(ee,Ye),ge(Ye,"display",""),Yt=!1}}};function ff(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function nn(r,e,t,n,o,s,i,a){var l,u=r[yt],c=u.options.onMove,f;return window.CustomEvent&&!Ht&&!Mr?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||tt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),c&&(f=c.call(u,l,i)),f}function ei(r){r.draggable=!1}function hf(){ii=!1}function pf(r,e,t){var n=tt(fr(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 mf(r,e,t){var n=tt(li(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 gf(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,u=n?t.height:t.width,c=n?t.top:t.left,f=n?t.bottom:t.right,h=!1;if(!i){if(a&&an<u*o){if(!Pr&&(Or===1?l>c+u*s/2:l<f-u*s/2)&&(Pr=!0),Pr)h=!0;else if(Or===1?l<c+an:l>f-an)return-Or}else if(l>c+u*(1-o)/2&&l<f-u*(1-o)/2)return vf(e)}return h=h||i,h&&(l<c+u*s/2||l>f-u*s/2)?l>c+u/2?1:-1:0}function vf(r){return St(ee)<St(r)?1:-1}function yf(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 bf(r){hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&hn.push(n)}}function ln(r){return setTimeout(r,0)}function oi(r){return clearTimeout(r)}mn&&Me(document,"touchmove",function(r){(ve.active||ur)&&r.cancelable&&r.preventDefault()});ve.utils={on:Me,off:Le,css:ge,find:Ts,is:function(e,t){return!!Lt(e,t,e,!1)},extend:ef,throttle:Is,closest:Lt,toggleClass:gt,clone:Ls,index:St,nextTick:ln,cancelNextTick:oi,detectDirection:Rs,getChild:fr};ve.get=function(r){return r[yt]};ve.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&&(ve.utils=Rt(Rt({},ve.utils),n.utils)),_r.mount(n)})};ve.create=function(r,e){return new ve(r,e)};ve.version=Zd;var Je=[],Ir,si,ai=!1,ti,ri,pn,Dr;function xf(){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?Me(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Me(document,"pointermove",this._handleFallbackAutoScroll):n.touches?Me(document,"touchmove",this._handleFallbackAutoScroll):Me(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Le(document,"dragover",this._handleAutoScroll):(Le(document,"pointermove",this._handleFallbackAutoScroll),Le(document,"touchmove",this._handleFallbackAutoScroll),Le(document,"mousemove",this._handleFallbackAutoScroll)),Ss(),un(),tf()},nulling:function(){pn=si=Ir=ai=Dr=ti=ri=null,Je.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(pn=t,n||this.options.forceAutoScrollFallback||Mr||Ht||Lr){ni(t,this.options,a,n);var l=Kt(a,!0);ai&&(!Dr||s!==ti||i!==ri)&&(Dr&&Ss(),Dr=setInterval(function(){var u=Kt(document.elementFromPoint(s,i),!0);u!==l&&(l=u,un()),ni(t,o.options,u,n)},10),ti=s,ri=i)}else{if(!this.options.bubbleScroll||Kt(a,!0)===Ft()){un();return}ni(t,this.options,Kt(a,!1),!1)}}},jt(r,{pluginName:"scroll",initializeByDefault:!0})}function un(){Je.forEach(function(r){clearInterval(r.pid)}),Je=[]}function Ss(){clearInterval(Dr)}var ni=Is(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=Ft(),u=!1,c;si!==t&&(si=t,un(),Ir=e.scroll,c=e.scrollFn,Ir===!0&&(Ir=Kt(t,!0)));var f=0,h=Ir;do{var d=h,p=tt(d),m=p.top,v=p.bottom,b=p.left,x=p.right,C=p.width,S=p.height,M=void 0,A=void 0,O=d.scrollWidth,k=d.scrollHeight,D=ge(d),I=d.scrollLeft,P=d.scrollTop;d===l?(M=C<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),A=S<k&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=C<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),A=S<k&&(D.overflowY==="auto"||D.overflowY==="scroll"));var N=M&&(Math.abs(x-o)<=i&&I+C<O)-(Math.abs(b-o)<=i&&!!I),B=A&&(Math.abs(v-s)<=i&&P+S<k)-(Math.abs(m-s)<=i&&!!P);if(!Je[f])for(var H=0;H<=f;H++)Je[H]||(Je[H]={});(Je[f].vx!=N||Je[f].vy!=B||Je[f].el!==d)&&(Je[f].el=d,Je[f].vx=N,Je[f].vy=B,clearInterval(Je[f].pid),(N!=0||B!=0)&&(u=!0,Je[f].pid=setInterval(function(){n&&this.layer===0&&ve.active._onTouchMove(pn);var Z=Je[this.layer].vy?Je[this.layer].vy*a:0,W=Je[this.layer].vx?Je[this.layer].vx*a:0;typeof c=="function"&&c.call(ve.dragged.parentNode[yt],W,Z,r,pn,Je[this.layer].el)!=="continue"||Ds(Je[this.layer].el,W,Z)}.bind({layer:f}),24))),f++}while(e.bubbleScroll&&h!==l&&(h=Kt(h,!1)));ai=u}},30),_s=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 u=n||s;a();var c=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,f=document.elementFromPoint(c.clientX,c.clientY);l(),u&&!u.el.contains(f)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function ui(){}ui.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=fr(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:_s};jt(ui,{pluginName:"revertOnSpill"});function ci(){}ci.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:_s};jt(ci,{pluginName:"removeOnSpill"});ve.mount(new xf);ve.mount(ci,ui);var hr=ve;var Ns={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}},di=class{constructor(e){this.elem=e,this.sortContainer=e.querySelector("[book-sort-boxes]"),this.input=e.querySelector("[book-sort-input]");let t=e.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),window.$events.listen("entity-select-confirm",this.bookSelect.bind(this))}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=Ns[a];t&&n.includes(a)&&(l=function(u,c){return 0-Ns[a](u,c)});for(let u of i)Array.from(u.children).filter(f=>f.matches("li")).sort(l).forEach(f=>{u.appendChild(f)});e=a,this.updateMapInput()})}bookSelect(e){if(this.elem.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=document.createElement("div");s.innerHTML=o.data;let i=s.children[0];this.sortContainer.append(i),this.setupBookSortable(i)})}setupBookSortable(e){let t=[e.querySelector(".sort-list")];t.push(...e.querySelectorAll(".entity-list-item + ul"));let 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)new hr(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:this.updateMapInput.bind(this),dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"CTRL",selectedClass:"sortable-selected"})}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.elem.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 u=0;u<l.length;u++)o.push({id:l[u].getAttribute("data-id"),sort:u,parentChapter:a,type:"page",book:n})}},Bs=di;var gn=new WeakMap;function $s(r,e=400,t=null){Br(r),r.style.display="block",Nr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function vn(r,e=400,t=null){Br(r),Nr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function pr(r,e=400){Br(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"]};Nr(r,i,e,()=>{r.style.display="none"})}function mr(r,e=400){Br(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]};Nr(r,i,e)}function Us(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{Br(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),u=a.getPropertyValue("padding-bottom"),c={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,u]};Nr(r,c,e)}}function Nr(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),gn.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),gn.set(r,s)},15)}function Br(r){gn.has(r)&&gn.get(r)()}var fi=class{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"),mr(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),pr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}},zs=fi;var hi=class{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()}),Be(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),Jr(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Be(this.saveButton,e=>this.save()),qe(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"),qe(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("/settings/users/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.popup.components.popup.show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.popup.components.popup.hide(),this.addHistory()}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)}},js=hi;var pi=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},Hs=pi;var mi=class{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}},qs=mi;var gi=class{constructor(e){this.elem=e,this.trigger=e.querySelector("[collapsible-trigger]"),this.content=e.querySelector("[collapsible-content]"),this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.elem.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),mr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),pr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},Vs=gi;var vi=class{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Be(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 this.container.components.popup}sendResult(e){this.res&&(this.res(e),this.res=null)}},Gs=vi;var yi=class{constructor(e){this.elem=e,this.checkbox=e.querySelector("input[type=checkbox]"),this.display=e.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.elem.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.keyCode===32||e.keyCode===13)&&(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)}},Ws=yi;var bi=class{constructor(e){this.elem=e,this.dealtWith=!1,e.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.elem.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.elem)}),this.dealtWith=!0)}},Ys=bi;var xi=class{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.setupListeners(),this.hide=this.hide.bind(this)}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.bind(this)),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.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}getFocusable(){return Array.from(this.menu.querySelectorAll('[tabindex]:not([tabindex="-1"]),[href],button,input:not([type=hidden])'))}focusNext(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}setupListeners(){this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Be(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&this.focusNext()});let e=t=>{t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"&&(this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation())};this.container.addEventListener("keydown",e),this.moveMenu&&this.menu.addEventListener("keydown",e),this.menu.addEventListener("keydown ",t=>{t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.hide())})}},Ks=xi;var wi=class{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=Ar(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=Us(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"}},Xs=wi;var Qs=Yr(Zs());var Si=class{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 Qs.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),vn(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)}},Js=Si;var Ci=class{constructor(e){this.elem=e,this.buttons=e.querySelectorAll("[toolbox-tab-button]"),this.contentElements=e.querySelectorAll("[toolbox-tab-content]"),this.toggleButton=e.querySelector("[toolbox-toggle]"),this.toggleButton.addEventListener("click",this.toggle.bind(this)),this.elem.addEventListener("click",t=>{let n=t.target.closest("[toolbox-tab-button]");if(n===null)return;let o=n.getAttribute("toolbox-tab-button");this.setActiveTab(o,!0)}),this.setActiveTab(this.contentElements[0].getAttribute("toolbox-tab-content"))}toggle(){this.elem.classList.toggle("open");let e=this.elem.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n=0,o=this.buttons.length;n<o;n++)this.buttons[n].classList.remove("active"),this.buttons[n].getAttribute("toolbox-tab-button")===e&&this.buttons[n].classList.add("active");for(let n=0,o=this.contentElements.length;n<o;n++)this.contentElements[n].style.display="none",this.contentElements[n].getAttribute("toolbox-tab-content")===e&&(this.contentElements[n].style.display="block");t&&!this.elem.classList.contains("open")&&this.toggle()}},ea=Ci;var Ai=class{constructor(e){this.permissionsTable=e.querySelector("[permissions-table]"),this.restrictedCheckbox=e.querySelector("[name=restricted]"),this.restrictedCheckbox.addEventListener("change",this.updateTableVisibility.bind(this))}updateTableVisibility(){this.permissionsTable.style.display=this.restrictedCheckbox.checked?null:"none"}},ta=Ai;var ki=class{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()}),Be(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=""}},ra=ki;var Ti=class{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.addButton=this.$refs.add,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()}),this.addButton&&this.addButton.addEventListener("click",t=>{this.selectedItemData&&(this.confirmSelection(this.selectedItemData),this.unselectAll())}),qe(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`/ajax/search/entities?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}},na=Ti;var Ii=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,window.EntitySelectorPopup=this,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.elem.components.popup.show(),this.getSelector().focusSearch()}hide(){this.elem.components.popup.hide()}getSelector(){return this.selectorEl.components["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)}},ia=Ii;var Di=class{setup(){this.container=this.$el,this.name=this.$opts.name,Be(this.$el,()=>{this.$emit(this.name,this.$opts)})}},oa=Di;var Li=class{constructor(e){this.elem=e,this.isOpen=e.getAttribute("expand-toggle-is-open")==="yes",this.updateEndpoint=e.getAttribute("expand-toggle-update-endpoint"),this.selector=e.getAttribute("expand-toggle"),e.addEventListener("click",this.click.bind(this))}open(e){mr(e,200)}close(e){pr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.selector);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"})}},sa=Li;var Fi=class{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)}},aa=Fi;var Ri=class{constructor(e){this.elem=e,this.typeControl=e.querySelector('[name="setting-app-homepage-type"]'),this.pagePickerContainer=e.querySelector("[page-picker-container]"),this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}},la=Ri;var Oi=class{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(),window.ImageManager=this}setupListeners(){Be(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()}),Be(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())}),qe(this.listContainer,".load-more","click",async e=>{Cr(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),Be(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),qe(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.popupEl.components.popup.show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.popupEl.components.popup.hide()}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),is(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){this.filterTabs.forEach(n=>n.classList.remove("selected"));let t=this.filterTabs.find(n=>n.dataset.filter===e);t&&t.classList.add("selected")}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(){Cr(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)}},ua=Oi;var Pi=class{constructor(e){this.elem=e,this.imageElem=e.querySelector("img"),this.imageInput=e.querySelector("input[type=file]"),this.resetInput=e.querySelector("input[data-reset-input]"),this.removeInput=e.querySelector("input[data-remove-input]"),this.defaultImage=e.getAttribute("data-default-image"),e.querySelector('button[data-action="reset-image"]').addEventListener("click",this.reset.bind(this));let n=e.querySelector('button[data-action="remove-image"]');n&&n.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")}},ca=Pi;var Mi=class{constructor(e){this.elem=e,this.menu=e.querySelector("ul"),this.sortInput=e.querySelector('[name="sort"]'),this.orderInput=e.querySelector('[name="order"]'),this.form=e.querySelector("form"),this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}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 n=this.orderInput.value==="asc"?"desc":"asc";this.orderInput.value=n,e.preventDefault(),this.form.submit()}},da=Mi;var Dc=Yr(vc()),Lc=Yr(Ec());var ho=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}},Hr=ho;function Hp(r,e){return document.createElement(r,e)}function qp(r,e,t){return document.createElementNS(r,e,t)}function Vp(){return document.createDocumentFragment()}function Gp(r){return document.createTextNode(r)}function Wp(r){return document.createComment(r)}function Yp(r,e,t){r.insertBefore(e,t)}function Kp(r,e){r.removeChild(e)}function Xp(r,e){r.appendChild(e)}function Zp(r){return r.parentNode}function Qp(r){return r.nextSibling}function Jp(r){return r.tagName}function em(r,e){r.textContent=e}function tm(r){return r.textContent}function rm(r){return r.nodeType===1}function nm(r){return r.nodeType===3}function im(r){return r.nodeType===8}function om(r){return r.nodeType===11}var On={createElement:Hp,createElementNS:qp,createTextNode:Gp,createDocumentFragment:Vp,createComment:Wp,insertBefore:Yp,removeChild:Kp,appendChild:Xp,parentNode:Zp,nextSibling:Qp,tagName:Jp,setTextContent:em,getTextContent:tm,isElement:rm,isText:nm,isComment:im,isDocumentFragment:om};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 Sc=Array.isArray;function Cc(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function po(r){return r===void 0}function pt(r){return r!==void 0}var mo=qt("",{},[],void 0,void 0);function qr(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);return r.sel===e.sel&&o&&s}function am(){throw new Error("The document fragment is not supported on this platform.")}function lm(r,e){return r.isElement(e)}function um(r,e){return r.isDocumentFragment(e)}function cm(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 dm=["create","update","remove","destroy","pre","post"];function go(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:On;for(let p of dm)for(let m of r){let v=m[p];v!==void 0&&n[p].push(v)}function s(p){let m=p.id?"#"+p.id:"",v=p.getAttribute("class"),b=v?"."+v.split(" ").join("."):"";return qt(o.tagName(p).toLowerCase()+m+b,{},[],void 0,p)}function i(p){return qt(void 0,{},[],void 0,p)}function a(p,m){return function(){if(--m===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,m){var v,b,x,C;let S,M=p.data;if(M!==void 0){let k=(v=M.hook)===null||v===void 0?void 0:v.init;pt(k)&&(k(p),M=p.data)}let A=p.children,O=p.sel;if(O==="!")po(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(O!==void 0){let k=O.indexOf("#"),D=O.indexOf(".",k),I=k>0?k:O.length,P=D>0?D:O.length,N=k!==-1||D!==-1?O.slice(0,Math.min(I,P)):O,B=p.elm=pt(M)&&pt(S=M.ns)?o.createElementNS(S,N,M):o.createElement(N,M);for(I<P&&B.setAttribute("id",O.slice(I+1,P)),D>0&&B.setAttribute("class",O.slice(P+1).replace(/\./g," ")),S=0;S<n.create.length;++S)n.create[S](mo,p);if(Sc(A))for(S=0;S<A.length;++S){let Z=A[S];Z!=null&&o.appendChild(B,l(Z,m))}else Cc(p.text)&&o.appendChild(B,o.createTextNode(p.text));let H=p.data.hook;pt(H)&&((b=H.create)===null||b===void 0||b.call(H,mo,p),H.insert&&m.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let k=p.children;for(p.elm=((C=o.createDocumentFragment)!==null&&C!==void 0?C:am)(),S=0;S<n.create.length;++S)n.create[S](mo,p);for(S=0;S<k.length;++S){let D=k[S];D!=null&&o.appendChild(p.elm,l(D,m))}}else p.elm=o.createTextNode(p.text);return p.elm}function u(p,m,v,b,x,C){for(;b<=x;++b){let S=v[b];S!=null&&o.insertBefore(p,l(S,C),m)}}function c(p){var m,v;let b=p.data;if(b!==void 0){(v=(m=b?.hook)===null||m===void 0?void 0:m.destroy)===null||v===void 0||v.call(m,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 C=p.children[x];C!=null&&typeof C!="string"&&c(C)}}}function f(p,m,v,b){for(var x,C;v<=b;++v){let S,M,A=m[v];if(A!=null)if(pt(A.sel)){c(A),S=n.remove.length+1,M=a(A.elm,S);for(let k=0;k<n.remove.length;++k)n.remove[k](A,M);let O=(C=(x=A?.data)===null||x===void 0?void 0:x.hook)===null||C===void 0?void 0:C.remove;pt(O)?O(A,M):M()}else o.removeChild(p,A.elm)}}function h(p,m,v,b){let x=0,C=0,S=m.length-1,M=m[0],A=m[S],O=v.length-1,k=v[0],D=v[O],I,P,N,B;for(;x<=S&&C<=O;)M==null?M=m[++x]:A==null?A=m[--S]:k==null?k=v[++C]:D==null?D=v[--O]:qr(M,k)?(d(M,k,b),M=m[++x],k=v[++C]):qr(A,D)?(d(A,D,b),A=m[--S],D=v[--O]):qr(M,D)?(d(M,D,b),o.insertBefore(p,M.elm,o.nextSibling(A.elm)),M=m[++x],D=v[--O]):qr(A,k)?(d(A,k,b),o.insertBefore(p,A.elm,M.elm),A=m[--S],k=v[++C]):(I===void 0&&(I=cm(m,x,S)),P=I[k.key],po(P)?o.insertBefore(p,l(k,b),M.elm):(N=m[P],N.sel!==k.sel?o.insertBefore(p,l(k,b),M.elm):(d(N,k,b),m[P]=void 0,o.insertBefore(p,N.elm,M.elm))),k=v[++C]);C<=O&&(B=v[O+1]==null?null:v[O+1].elm,u(p,B,v,C,O,b)),x<=S&&f(p,m,x,S)}function d(p,m,v){var b,x,C,S,M,A,O,k;let D=(b=m.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,m);let I=m.elm=p.elm,P=p.children,N=m.children;if(p!==m){if(m.data!==void 0||pt(m.text)&&m.text!==p.text){(C=m.data)!==null&&C!==void 0||(m.data={}),(S=p.data)!==null&&S!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,m);(O=(A=(M=m.data)===null||M===void 0?void 0:M.hook)===null||A===void 0?void 0:A.update)===null||O===void 0||O.call(A,p,m)}po(m.text)?pt(P)&&pt(N)?P!==N&&h(I,P,N,v):pt(N)?(pt(p.text)&&o.setTextContent(I,""),u(I,null,N,0,N.length-1,v)):pt(P)?f(I,P,0,P.length-1):pt(p.text)&&o.setTextContent(I,""):p.text!==m.text&&(pt(P)&&f(I,P,0,P.length-1),o.setTextContent(I,m.text)),(k=D?.postpatch)===null||k===void 0||k.call(D,p,m)}}return function(m,v){let b,x,C,S=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(lm(o,m)?m=s(m):um(o,m)&&(m=i(m)),qr(m,v)?d(m,v,S):(x=m.elm,C=o.parentNode(x),l(v,S),C!==null&&(o.insertBefore(C,v.elm,o.nextSibling(x)),f(C,[m],0,0))),b=0;b<S.length;++b)S[b].data.hook.insert(S[b]);for(b=0;b<n.post.length;++b)n.post[b]();return v}}function vo(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&&vo(s,o.children,o.sel)}}function Vr(r,e){let t=e!==void 0?e:On,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={},u={},c={},f=[],h,d,p,m=r.attributes,v=r.childNodes;for(d=0,p=m.length;d<p;d++)h=m[d].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?u[h.slice(5)]=m[d].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=m[d].nodeValue);for(d=0,p=v.length;d<p;d++)f.push(Vr(v[d],e));return Object.keys(l).length>0&&(c.attrs=l),Object.keys(u).length>0&&(c.datasets=u),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&vo(c,f,a),qt(a,c,f,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 fm="http://www.w3.org/1999/xlink",hm="http://www.w3.org/XML/1998/namespace";function Ac(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(hm,t,i):t.charCodeAt(5)===58?n.setAttributeNS(fm,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var yo={create:Ac,update:Ac};var Pn;function pm(){return Pn||(Pn=go([yo]),Pn)}function kc(r,e){let t=document.createElement("div");t.innerHTML=e,pm()(Vr(r),Vr(t))}var _t=null,wo,bo,xo;function mm(r,e,t){bo=e,xo=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tc),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),wo=new URL(r).origin}function gm(){Ic()}function Tc(r){if(!r.data||r.data.length<1||r.origin!==wo)return;let e=JSON.parse(r.data);e.event==="init"?bm():e.event==="exit"?Ic():e.event==="save"?ym(e):e.event==="export"?vm(e):e.event==="configure"&&xm()}function vm(r){xo&&xo(r.data)}function ym(r){Eo({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function bm(){!bo||bo().then(r=>{Eo({action:"load",autosave:1,xml:r})})}function xm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),Eo({action:"configure",config:r})}function Ic(){window.removeEventListener("message",Tc),_t&&document.body.removeChild(_t)}function Eo(r){_t.contentWindow.postMessage(JSON.stringify(r),wo)}async function wm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function Em(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var xt={show:mm,close:gm,upload:wm,load:Em};var So=class{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.markdown=new Dc.default({html:!0}),this.markdown.use(Lc.default,{label:!0}),this.display=this.elem.querySelector(".markdown-display"),this.displayStylesLoaded=!1,this.input=this.elem.querySelector("textarea"),this.cm=null,this.Code=null;let e=window.importVersioned("code").then(n=>(this.cm=n.markdownEditor(this.input),this.Code=n,this.cm));this.onMarkdownScroll=this.onMarkdownScroll.bind(this);let t=()=>{this.displayDoc=this.display.contentDocument,this.init(e)};this.display.contentDocument.readyState==="complete"?t():this.display.addEventListener("load",t.bind(this)),window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.markdown,displayEl:this.display,codeMirrorInstance:this.cm})}init(e){let t=0;this.displayDoc.addEventListener("click",s=>{let i=Date.now()-t<300,a=s.target.closest("a");if(a!==null){s.preventDefault(),window.open(a.getAttribute("href"));return}let l=s.target.closest("[drawio-diagram]");if(l!==null&&i){this.actionEditDrawing(l);return}t=Date.now()}),this.elem.addEventListener("click",s=>{let i=s.target.closest("button[data-action]");if(i===null)return;let a=i.getAttribute("data-action");if(a==="insertImage"&&this.actionInsertImage(),a==="insertLink"&&this.actionShowLinkSelector(),a==="insertDrawing"&&(s.ctrlKey||s.metaKey)){this.actionShowImageManager();return}a==="insertDrawing"&&this.actionStartDrawing(),a==="fullscreen"&&this.actionFullScreen()}),this.elem.addEventListener("click",s=>{let i=s.target.closest(".editor-toolbar-label");if(!i)return;let a=this.elem.querySelectorAll(".markdown-editor-wrap");for(let l of a)l.classList.remove("active");i.closest(".markdown-editor-wrap").classList.add("active")}),e.then(s=>{this.codeMirrorSetup(s);let i=Ar(()=>this.Code.updateLayout(s),100,!1);new ResizeObserver(i).observe(this.elem)}),this.listenForBookStackEditorEvents();let o=new URL(window.location).searchParams.get("content-text");o&&this.scrollToText(o)}updateAndRender(){let e=this.cm.getValue();this.input.value=e;let t=this.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e);let n=this.getDisplayTarget();this.displayDoc.body.className="page-content",kc(n,t),this.loadStylesIntoDisplay()}getDisplayTarget(){let e=this.displayDoc.body;if(e.children.length===0){let t=document.createElement("div");this.displayDoc.body.append(t)}return e.children[0]}loadStylesIntoDisplay(){if(this.displayStylesLoaded)return;this.displayDoc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.displayDoc.documentElement.style.backgroundColor="#222",this.displayDoc.documentElement.classList.add("dark-mode")),this.displayDoc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.displayDoc.head.appendChild(n)}this.displayStylesLoaded=!0}onMarkdownScroll(e){let t=this.displayDoc.body.children;if(t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}codeMirrorSetup(e){let t=this;e.setOption("direction","ltr");let n=this.Code.getMetaKey(),o={};o[`${n}-Alt-I`]=function(d){let m=``,v=d.getCursor("from");d.replaceSelection(m),d.setCursor(v.line,v.ch+m.length-1)},o[`${n}-S`]=d=>{window.$events.emit("editor-save-draft")},o[`${n}-Enter`]=d=>{window.$events.emit("editor-save-page")},o[`Shift-${n}-K`]=d=>{this.actionShowLinkSelector()},o[`${n}-K`]=d=>{h()},o[`${n}-1`]=d=>{a("##")},o[`${n}-2`]=d=>{a("###")},o[`${n}-3`]=d=>{a("####")},o[`${n}-4`]=d=>{a("#####")},o[`${n}-5`]=d=>{a("")},o[`${n}-D`]=d=>{a("")},o[`${n}-6`]=d=>{a(">")},o[`${n}-Q`]=d=>{a(">")},o[`${n}-7`]=d=>{u("\n```\n","\n```")},o[`${n}-8`]=d=>{u("`","`")},o[`Shift-${n}-E`]=d=>{u("`","`")},o[`${n}-9`]=d=>{u('<p class="callout info">',"</p>")},o[`${n}-P`]=d=>{a("-")},o[`${n}-O`]=d=>{c()},e.setOption("extraKeys",o),e.on("change",(d,p)=>{this.updateAndRender()});let s=Ar(d=>{let p=d.getScrollInfo();if(p.top+p.clientHeight===p.height){this.onMarkdownScroll(-1);return}let v=d.lineAtHeight(p.top,"local"),b=d.getRange({line:0,ch:null},{line:v,ch:null}),S=new DOMParser().parseFromString(this.markdown.render(b),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(S.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,p)=>{let m=new Hr(p.clipboardData||p.dataTransfer);if(!m.hasItems()||m.containsTabularData())return;let v=m.getImages();for(let b of v)f(b)}),e.on("drop",(d,p)=>{let m=p.dataTransfer.getData("bookstack/template");if(m){let b=d.coordsChar({left:p.pageX,top:p.pageY});d.setCursor(b),p.preventDefault(),window.$http.get(`/templates/${m}`).then(x=>{let C=x.data.markdown||x.data.html;d.replaceSelection(C)})}let v=new Hr(p.dataTransfer);if(v.hasItems()&&v.getImages().length>0){let b=d.coordsChar({left:p.pageX,top:p.pageY});d.setCursor(b),p.stopPropagation(),p.preventDefault();let x=v.getImages();for(let C of x)f(C)}});function i(d,p){let m=e.getValue(),v=e.listSelections();e.setValue(m.replace(d,p)),e.setSelections(v)}function a(d){let p=e.getCursor(),m=e.getLine(p.line),v=m.length,b=m.split(" ")[0];if(b===d){m=m.replace(`${d} `,""),e.replaceRange(m,{line:p.line,ch:0},{line:p.line,ch:v}),e.setCursor({line:p.line,ch:p.ch-(d.length+1)});return}let x=/^[#>`]/.test(b),C=0;x?(C=d.length-b.length,m=m.replace(b,d).trim()):d!==""&&(C=d.length+1,m=d+" "+m),e.replaceRange(m,{line:p.line,ch:0},{line:p.line,ch:v}),e.setCursor({line:p.line,ch:p.ch+C})}function l(d,p){let m=e.getCursor(),v=e.getLine(m.line),b=v.length,x=v;v.indexOf(d)===0&&v.slice(-p.length)===p?x=v.slice(d.length,v.length-p.length):x=`${d}${v}${p}`,e.replaceRange(x,{line:m.line,ch:0},{line:m.line,ch:b}),e.setCursor({line:m.line,ch:m.ch+d.length})}function u(d,p){let m=e.getSelection();if(m==="")return l(d,p);let v=m,b=0,x=0;m.indexOf(d)===0&&m.slice(-p.length)===p?(v=m.slice(d.length,m.length-p.length),x=-(p.length+d.length)):(v=`${d}${m}${p}`,x=d.length+p.length);let C=e.listSelections()[0];e.replaceSelection(v);let S=C.head.ch<=C.anchor.ch;C.head.ch+=S?b:x,C.anchor.ch+=S?x:b,e.setSelections([C])}function c(){let d=e.getCursor(),m=(e.getLine(d.line-1)||"").match(/^(\s*)(\d)([).])\s/)||[],v=(Number(m[2])||0)+1,b=m[1]||"",x=m[3]||".",C=`${b}${v}${x}`;return a(C)}function f(d){if(d===null||d.type.indexOf("image")!==0)return;let p="png";if(d.name){let A=d.name.match(/\.(.+)$/);A.length>1&&(p=A[1])}let m="image-"+Math.random().toString(16).slice(2),v=window.baseUrl(`/loading.gif#upload${m}`),b=e.getSelection(),x=``,C=e.getCursor();e.replaceSelection(x),e.setCursor({line:C.line,ch:C.ch+b.length+3});let S="image-"+Date.now()+"."+p,M=new FormData;M.append("file",d,S),M.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",M).then(A=>{let O=`[](${A.data.url})`;i(x,O)}).catch(A=>{window.$events.emit("error",t.imageUploadErrorText),i(x,b),console.log(A)})}function h(){let d=e.getCursor("from"),p=e.getSelection()||"",m=`[${p}]()`;e.focus(),e.replaceSelection(m);let v=p===""?-3:-1;e.setCursor(d.line,d.ch+m.length+v)}this.updateAndRender()}actionInsertImage(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{let n=t.thumbs.display||t.url,o=this.cm.getSelection(),s="[]("+t.url+")";this.cm.focus(),this.cm.replaceSelection(s),this.cm.setCursor(e.line,e.ch+s.length)},"gallery")}actionShowImageManager(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{this.insertDrawing(t,e)},"drawio")}actionShowLinkSelector(){let e=this.cm.getCursor("from");window.EntitySelectorPopup.show(t=>{let o=`[${this.cm.getSelection()||t.name}](${t.link})`;this.cm.focus(),this.cm.replaceSelection(o),this.cm.setCursor(e.line,e.ch+o.length)})}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):!1}actionStartDrawing(){let e=this.getDrawioUrl();if(!e)return;let t=this.cm.getCursor("from");xt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),xt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.cm.focus(),this.cm.replaceSelection(n),this.cm.setCursor(t.line,t.ch+n.length)}actionEditDrawing(e){let t=this.getDrawioUrl();if(!t)return;let n=this.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");xt.show(t,()=>xt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,u=this.cm.getValue().split(`