diff --git a/public/dist/app.js b/public/dist/app.js index 4fb5ebe80..d5a2d152e 100644 --- a/public/dist/app.js +++ b/public/dist/app.js @@ -22,14 +22,14 @@ Expect errors in decoding.`),E=E.replace(/[^A-Za-z0-9\+\/\=]/g,"");P=this.KEY_ST `);return n};mr.prototype.render=function(r,e,t){var n,o,s,i="",a=this.rules;for(n=0,o=r.length;n{"use strict";function At(){this.__rules__=[],this.__cache__=null}At.prototype.__find__=function(r){for(var e=0;e{"use strict";var Of=/\r\n?|\n/g,Pf=/\0/g;ca.exports=function(e){var t;t=e.src.replace(Of,` `),t=t.replace(Pf,"\uFFFD"),e.src=t}});var ha=ie((xg,fa)=>{"use strict";fa.exports=function(e){var t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}});var ma=ie((wg,pa)=>{"use strict";pa.exports=function(e){var t=e.tokens,n,o,s;for(o=0,s=t.length;o{"use strict";var Mf=Ne().arrayReplaceAt;function Nf(r){return/^\s]/i.test(r)}function _f(r){return/^<\/a\s*>/i.test(r)}ga.exports=function(e){var t,n,o,s,i,a,l,u,c,f,d,h,m,v,y,w,x=e.tokens,D;if(!!e.md.options.linkify){for(n=0,o=x.length;n=0;t--){if(a=s[t],a.type==="link_close"){for(t--;s[t].level!==a.level&&s[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(Nf(a.content)&&m>0&&m--,_f(a.content)&&m++),!(m>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(c=a.content,D=e.md.linkify.match(c),l=[],h=a.level,d=0,u=0;ud&&(i=new e.Token("text","",0),i.content=c.slice(d,f),i.level=h,l.push(i)),i=new e.Token("link_open","a",1),i.attrs=[["href",y]],i.level=h++,i.markup="linkify",i.info="auto",l.push(i),i=new e.Token("text","",0),i.content=w,i.level=h,l.push(i),i=new e.Token("link_close","a",-1),i.level=--h,i.markup="linkify",i.info="auto",l.push(i),d=D[u].lastIndex);d{"use strict";var ya=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Bf=/\((c|tm|r|p)\)/i,$f=/\((c|tm|r|p)\)/ig,Uf={c:"\xA9",r:"\xAE",p:"\xA7",tm:"\u2122"};function zf(r,e){return Uf[e.toLowerCase()]}function jf(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&(t.content=t.content.replace($f,zf)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function Hf(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&ya.test(t.content)&&(t.content=t.content.replace(/\+-/g,"\xB1").replace(/\.{2,}/g,"\u2026").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1\u2014").replace(/(^|\s)--(?=\s|$)/mg,"$1\u2013").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1\u2013")),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}ba.exports=function(e){var t;if(!!e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(Bf.test(e.tokens[t].content)&&jf(e.tokens[t].children),ya.test(e.tokens[t].content)&&Hf(e.tokens[t].children))}});var Ta=ie((Cg,ka)=>{"use strict";var wa=Ne().isWhiteSpace,Ea=Ne().isPunctChar,Sa=Ne().isMdAsciiPunct,qf=/['"]/,Ca=/['"]/g,Aa="\u2019";function wn(r,e,t){return r.substr(0,e)+t+r.substr(e+1)}function Vf(r,e){var t,n,o,s,i,a,l,u,c,f,d,h,m,v,y,w,x,D,I,N,S;for(I=[],t=0;t=0&&!(I[x].level<=l);x--);if(I.length=x+1,n.type!=="text")continue;o=n.content,i=0,a=o.length;e:for(;i=0)c=o.charCodeAt(s.index-1);else for(x=t-1;x>=0&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x--)if(!!r[x].content){c=r[x].content.charCodeAt(r[x].content.length-1);break}if(f=32,i=48&&c<=57&&(w=y=!1),y&&w&&(y=d,w=h),!y&&!w){D&&(n.content=wn(n.content,s.index,Aa));continue}if(w){for(x=I.length-1;x>=0&&(u=I[x],!(I[x].level=0;t--)e.tokens[t].type!=="inline"||!qf.test(e.tokens[t].content)||Vf(e.tokens[t].children,e)}});var En=ie((Ag,Ia)=>{"use strict";function gr(r,e,t){this.type=r,this.tag=e,this.attrs=null,this.map=null,this.nesting=t,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}gr.prototype.attrIndex=function(e){var t,n,o;if(!this.attrs)return-1;for(t=this.attrs,n=0,o=t.length;n=0&&(n=this.attrs[t][1]),n};gr.prototype.attrJoin=function(e,t){var n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+" "+t};Ia.exports=gr});var Fa=ie((kg,La)=>{"use strict";var Gf=En();function Da(r,e,t){this.src=r,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}Da.prototype.Token=Gf;La.exports=Da});var Oa=ie((Tg,Ra)=>{"use strict";var Wf=xn(),ii=[["normalize",da()],["block",ha()],["inline",ma()],["linkify",va()],["replacements",xa()],["smartquotes",Ta()]];function oi(){this.ruler=new Wf;for(var r=0;r{"use strict";var si=Ne().isSpace;function ai(r,e){var t=r.bMarks[e]+r.tShift[e],n=r.eMarks[e];return r.src.substr(t,n-t)}function Pa(r){var e=[],t=0,n=r.length,o,s=!1,i=0,a="";for(o=r.charCodeAt(t);tn||(c=t+1,e.sCount[c]=4||(a=e.bMarks[c]+e.tShift[c],a>=e.eMarks[c])||(N=e.src.charCodeAt(a++),N!==124&&N!==45&&N!==58)||a>=e.eMarks[c]||(S=e.src.charCodeAt(a++),S!==124&&S!==45&&S!==58&&!si(S))||N===45&&si(S))return!1;for(;a=4||(f=Pa(i),f.length&&f[0]===""&&f.shift(),f.length&&f[f.length-1]===""&&f.pop(),d=f.length,d===0||d!==m.length))return!1;if(o)return!0;for(x=e.parentType,e.parentType="table",I=e.md.block.ruler.getRules("blockquote"),h=e.push("table_open","table",1),h.map=y=[t,0],h=e.push("thead_open","thead",1),h.map=[t,t+1],h=e.push("tr_open","tr",1),h.map=[t,t+1],l=0;l=4)break;for(f=Pa(i),f.length&&f[0]===""&&f.shift(),f.length&&f[f.length-1]===""&&f.pop(),c===t+2&&(h=e.push("tbody_open","tbody",1),h.map=w=[t+2,0]),h=e.push("tr_open","tr",1),h.map=[c,c+1],l=0;l{"use strict";_a.exports=function(e,t,n){var o,s,i;if(e.sCount[t]-e.blkIndent<4)return!1;for(s=o=t+1;o=4){o++,s=o;continue}break}return e.line=s,i=e.push("code_block","code",0),i.content=e.getLines(t,s,4+e.blkIndent,!1)+` `,i.map=[t,e.line],!0}});var Ua=ie((Lg,$a)=>{"use strict";$a.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d=!1,h=e.bMarks[t]+e.tShift[t],m=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||h+3>m||(s=e.src.charCodeAt(h),s!==126&&s!==96)||(u=h,h=e.skipChars(h,s),i=h-u,i<3)||(f=e.src.slice(u,h),a=e.src.slice(h,m),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(o)return!0;for(l=t;l++,!(l>=n||(h=u=e.bMarks[l]+e.tShift[l],m=e.eMarks[l],h=4)&&(h=e.skipChars(h,s),!(h-u{"use strict";var za=Ne().isSpace;ja.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,m,v,y,w,x,D,I,N,S,M,L,R=e.lineMax,O=e.bMarks[t]+e.tShift[t],F=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(O++)!==62)return!1;if(o)return!0;for(l=h=e.sCount[t]+1,e.src.charCodeAt(O)===32?(O++,l++,h++,s=!1,I=!0):e.src.charCodeAt(O)===9?(I=!0,(e.bsCount[t]+h)%4===3?(O++,l++,h++,s=!1):s=!0):I=!1,m=[e.bMarks[t]],e.bMarks[t]=O;O=F,x=[e.sCount[t]],e.sCount[t]=h-l,D=[e.tShift[t]],e.tShift[t]=O-e.bMarks[t],S=e.md.block.ruler.getRules("blockquote"),w=e.parentType,e.parentType="blockquote",d=t+1;d=F));d++){if(e.src.charCodeAt(O++)===62&&!L){for(l=h=e.sCount[d]+1,e.src.charCodeAt(O)===32?(O++,l++,h++,s=!1,I=!0):e.src.charCodeAt(O)===9?(I=!0,(e.bsCount[d]+h)%4===3?(O++,l++,h++,s=!1):s=!0):I=!1,m.push(e.bMarks[d]),e.bMarks[d]=O;O=F,v.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(I?1:0),x.push(e.sCount[d]),e.sCount[d]=h-l,D.push(e.tShift[d]),e.tShift[d]=O-e.bMarks[d];continue}if(c)break;for(N=!1,a=0,u=S.length;a",M.map=f=[t,0],e.md.block.tokenize(e,t,d),M=e.push("blockquote_close","blockquote",-1),M.markup=">",e.lineMax=R,e.parentType=w,f[1]=e.line,a=0;a{"use strict";var Yf=Ne().isSpace;qa.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{"use strict";var Ya=Ne().isSpace;function Ga(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=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=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]=e.blkIndent&&(J=!0),(F=Wa(e,t))>=0){if(f=!0,j=e.bMarks[t]+e.tShift[t],w=Number(e.src.slice(j,F-1)),J&&w!==1)return!1}else if((F=Ga(e,t))>=0)f=!1;else return!1;if(J&&e.skipSpaces(F)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(F-1),o)return!0;for(v=e.tokens.length,f?(W=e.push("ordered_list_open","ol",1),w!==1&&(W.attrs=[["start",w]])):W=e.push("bullet_list_open","ul",1),W.map=m=[t,0],W.markup=String.fromCharCode(y),D=t,_=!1,te=e.md.block.ruler.getRules("list"),S=e.parentType,e.parentType="list";D=x?u=1:u=I-c,u>4&&(u=1),l=c+u,W=e.push("list_item_open","li",1),W.markup=String.fromCharCode(y),W.map=d=[t,0],f&&(W.info=e.src.slice(j,F-1)),R=e.tight,L=e.tShift[t],M=e.sCount[t],N=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=i-e.bMarks[t],e.sCount[t]=I,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||_)&&(re=!1),_=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=N,e.tShift[t]=L,e.sCount[t]=M,e.tight=R,W=e.push("list_item_close","li",-1),W.markup=String.fromCharCode(y),D=t=e.line,d[1]=D,i=e.bMarks[t],D>=n||e.sCount[D]=4)break;for(H=!1,a=0,h=te.length;a{"use strict";var Xf=Ne().normalizeReference,Sn=Ne().isSpace;Za.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,m,v,y,w,x,D,I,N=0,S=e.bMarks[t]+e.tShift[t],M=e.eMarks[t],L=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(S)!==91)return!1;for(;++S3)&&!(e.sCount[L]<0)){for(x=!1,c=0,f=D.length;c"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:I,href:u}),e.parentType=m,e.line=t+N+1),!0)}});var el=ie((Mg,Ja)=>{"use strict";Ja.exports=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var ui=ie((Ng,li)=>{"use strict";var Zf="[a-zA-Z_:][a-zA-Z0-9:._-]*",Qf="[^\"'=<>`\\x00-\\x20]+",Jf="'[^']*'",eh='"[^"]*"',th="(?:"+Qf+"|"+Jf+"|"+eh+")",rh="(?:\\s+"+Zf+"(?:\\s*=\\s*"+th+")?)",tl="<[A-Za-z][A-Za-z0-9\\-]*"+rh+"*\\s*\\/?>",rl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",nh="|",ih="<[?][\\s\\S]*?[?]>",oh="]*>",sh="",ah=new RegExp("^(?:"+tl+"|"+rl+"|"+nh+"|"+ih+"|"+oh+"|"+sh+")"),lh=new RegExp("^(?:"+tl+"|"+rl+")");li.exports.HTML_TAG_RE=ah;li.exports.HTML_OPEN_CLOSE_TAG_RE=lh});var il=ie((_g,nl)=>{"use strict";var uh=el(),ch=ui().HTML_OPEN_CLOSE_TAG_RE,vr=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(ch.source+"\\s*$"),/^$/,!1]];nl.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{"use strict";var ol=Ne().isSpace;sl.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&&u6||uu&&ol(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 ul=ie(($g,ll)=>{"use strict";ll.exports=function(e,t,n){var o,s,i,a,l,u,c,f,d,h=t+1,m,v=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(m=e.parentType,e.parentType="paragraph";h3)){if(e.sCount[h]>=e.blkIndent&&(u=e.bMarks[h]+e.tShift[h],c=e.eMarks[h],u=c)))){f=d===61?1:2;break}if(!(e.sCount[h]<0)){for(s=!1,i=0,a=v.length;i{"use strict";cl.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";u3)&&!(e.sCount[u]<0)){for(o=!1,s=0,i=c.length;s{"use strict";var fl=En(),Cn=Ne().isSpace;function Ot(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;a0&&this.level++,this.tokens.push(n),n};Ot.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Ot.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;et;)if(!Cn(this.src.charCodeAt(--e)))return e+1;return e};Ot.prototype.skipChars=function(e,t){for(var n=this.src.length;en;)if(t!==this.src.charCodeAt(--e))return e+1;return e};Ot.prototype.getLines=function(e,t,n,o){var s,i,a,l,u,c,f,d=e;if(e>=t)return"";for(c=new Array(t-e),s=0;dn?c[s]=new Array(i-n+1).join(" ")+this.src.slice(l,u):c[s]=this.src.slice(l,u)}return c.join("")};Ot.prototype.Token=fl;hl.exports=Ot});var gl=ie((jg,ml)=>{"use strict";var dh=xn(),An=[["table",Na(),["paragraph","reference"]],["code",Ba()],["fence",Ua(),["paragraph","reference","blockquote","list"]],["blockquote",Ha(),["paragraph","reference","blockquote","list"]],["hr",Va(),["paragraph","reference","blockquote","list"]],["list",Xa(),["paragraph","reference","blockquote"]],["reference",Qa()],["html_block",il(),["paragraph","reference","blockquote"]],["heading",al(),["paragraph","reference","blockquote"]],["lheading",ul()],["paragraph",dl()]];function kn(){this.ruler=new dh;for(var r=0;r=t||r.sCount[a]=u){r.line=t;break}for(o=0;o{"use strict";function fh(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}}vl.exports=function(e,t){for(var n=e.pos;n{"use strict";var hh=Ne().isSpace;bl.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{"use strict";var ph=Ne().isSpace,di=[];for(ci=0;ci<256;ci++)di.push(0);var ci;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){di[r.charCodeAt(0)]=1});wl.exports=function(e,t){var n,o=e.pos,s=e.posMax;if(e.src.charCodeAt(o)!==92)return!1;if(o++,o{"use strict";Sl.exports=function(e,t){var n,o,s,i,a,l,u,c,f=e.pos,d=e.src.charCodeAt(f);if(d!==96)return!1;for(n=f,f++,o=e.posMax;f{"use strict";fi.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{"use strict";pi.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=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--))}pi.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(kl(e,e.delimiters),t=0;t{"use strict";var mh=Ne().normalizeReference,gi=Ne().isSpace;Tl.exports=function(e,t){var n,o,s,i,a,l,u,c,f,d="",h="",m=e.pos,v=e.posMax,y=e.pos,w=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,i=e.md.helpers.parseLinkLabel(e,e.pos,!0),i<0))return!1;if(l=i+1,l=v)return!1;if(y=l,u=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),u.ok){for(d=e.md.normalizeLink(u.str),e.md.validateLink(d)?l=u.pos:d="",y=l;l=v||e.src.charCodeAt(l)!==41)&&(w=!0),l++}if(w){if(typeof e.env.references>"u")return!1;if(l=0?s=e.src.slice(y,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),c=e.env.references[mh(s)],!c)return e.pos=m,!1;d=c.href,h=c.title}return t||(e.pos=a,e.posMax=i,f=e.push("link_open","a",1),f.attrs=n=[["href",d]],h&&n.push(["title",h]),e.md.inline.tokenize(e),f=e.push("link_close","a",-1)),e.pos=l,e.posMax=v,!0}});var Ll=ie((Xg,Dl)=>{"use strict";var gh=Ne().normalizeReference,vi=Ne().isSpace;Dl.exports=function(e,t){var n,o,s,i,a,l,u,c,f,d,h,m,v,y="",w=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)return!1;for(v=u,f=e.md.helpers.parseLinkDestination(e.src,u,e.posMax),f.ok&&(y=e.md.normalizeLink(f.str),e.md.validateLink(y)?u=f.pos:y=""),v=u;u=x||e.src.charCodeAt(u)!==41)return e.pos=w,!1;u++}else{if(typeof e.env.references>"u")return!1;if(u=0?i=e.src.slice(v,u++):u=a+1):u=a+1,i||(i=e.src.slice(l,a)),c=e.env.references[gh(i)],!c)return e.pos=w,!1;y=c.href,d=c.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,m=[]),h=e.push("image","img",0),h.attrs=n=[["src",y],["alt",""]],h.children=m,h.content=s,d&&n.push(["title",d])),e.pos=u,e.posMax=x,!0}});var Rl=ie((Zg,Fl)=>{"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])?)*)$/,yh=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Fl.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),yh.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 Pl=ie((Qg,Ol)=>{"use strict";var bh=ui().HTML_TAG_RE;function xh(r){var e=r|32;return e>=97&&e<=122}Ol.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(bh),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length)),e.pos+=o[0].length,!0)}});var Bl=ie((Jg,_l)=>{"use strict";var Ml=Jn(),wh=Ne().has,Eh=Ne().isValidEntityCode,Nl=Ne().fromCodePoint,Sh=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Ch=/^&([a-z][a-z0-9]{1,31});/i;_l.exports=function(e,t){var n,o,s,i=e.pos,a=e.posMax;if(e.src.charCodeAt(i)!==38)return!1;if(i+1{"use strict";function $l(r,e){var t,n,o,s,i,a,l,u,c={},f=e.length;if(!!f){var d=0,h=-2,m=[];for(t=0;ti;n-=m[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?m[n-1]+1:0,m[t]=t-n+u,m[n]=u,o.open=!1,s.end=t,s.close=!1,a=-1,h=-2;break}a!==-1&&(c[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Ul.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for($l(e,e.delimiters),t=0;t{"use strict";jl.exports=function(e){var t,n,o=0,s=e.tokens,i=e.tokens.length;for(t=n=0;t0&&o++,s[t].type==="text"&&t+1{"use strict";var yi=En(),ql=Ne().isWhiteSpace,Vl=Ne().isPunctChar,Gl=Ne().isMdAsciiPunct;function Nr(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}Nr.prototype.pushPending=function(){var r=new yi("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};Nr.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new yi(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};Nr.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,u,c,f,d=!0,h=!0,m=this.posMax,v=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t{"use strict";var Kl=xn(),bi=[["text",yl()],["newline",xl()],["escape",El()],["backticks",Cl()],["strikethrough",hi().tokenize],["emphasis",mi().tokenize],["link",Il()],["image",Ll()],["autolink",Rl()],["html_inline",Pl()],["entity",Bl()]],xi=[["balance_pairs",zl()],["strikethrough",hi().postProcess],["emphasis",mi().postProcess],["text_collapse",Hl()]];function _r(){var r;for(this.ruler=new Kl,r=0;r=s)break;continue}r.pending+=r.src[r.pos++]}r.pending&&r.pushPending()};_r.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{"use strict";Ql.exports=function(r){var e={};e.src_Any=ti().source,e.src_Cc=ri().source,e.src_Z=ni().source,e.src_P=mn().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+")(?!-|_|:\\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&&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 ou=ie((ov,iu)=>{"use strict";function wi(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 In(r){return Object.prototype.toString.call(r)}function Ah(r){return In(r)==="[object String]"}function kh(r){return In(r)==="[object Object]"}function Th(r){return In(r)==="[object RegExp]"}function eu(r){return In(r)==="[object Function]"}function Ih(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var nu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function Dh(r){return Object.keys(r||{}).reduce(function(e,t){return e||nu.hasOwnProperty(t)},!1)}var Lh={"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}}},Fh="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]",Rh="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function Oh(r){r.__index__=-1,r.__text_cache__=""}function Ph(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function tu(){return function(r,e){e.normalize(r)}}function Tn(r){var e=r.re=Jl()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(Fh),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,kh(l)){Th(l.validate)?u.validate=Ph(l.validate):eu(l.validate)?u.validate=l.validate:s(a,l),eu(l.normalize)?u.normalize=l.normalize:l.normalize?s(a,l):u.normalize=tu();return}if(Ah(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:tu()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(Ih).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.pretest=RegExp("("+r.re.schema_test.source+")|("+r.re.host_fuzzy_test.source+")|@","i"),Oh(r)}function Mh(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 ru(r,e){var t=new Mh(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function wt(r,e){if(!(this instanceof wt))return new wt(r,e);e||Dh(r)&&(e=r,r={}),this.__opts__=wi({},nu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=wi({},Lh,r),this.__compiled__={},this.__tlds__=Rh,this.__tlds_replaced__=!1,this.re={},Tn(this)}wt.prototype.add=function(e,t){return this.__schemas__[e]=t,Tn(this),this};wt.prototype.set=function(e){return this.__opts__=wi(this.__opts__,e),this};wt.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=0&&(o=e.match(this.re.email_fuzzy))!==null&&(i=o.index+o[1].length,a=o.index+o[0].length,(this.__index__<0||ithis.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=a))),this.__index__>=0};wt.prototype.pretest=function(e){return this.re.pretest.test(e)};wt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};wt.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(ru(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(ru(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};wt.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(),Tn(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Tn(this),this)};wt.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};wt.prototype.onCompile=function(){};iu.exports=wt});var hu={};ld(hu,{decode:()=>Ai,default:()=>Hh,encode:()=>ki,toASCII:()=>fu,toUnicode:()=>du,ucs2decode:()=>Ci,ucs2encode:()=>uu});function er(r){throw new RangeError($h[r])}function Uh(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function lu(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(Bh,".");let o=r.split("."),s=Uh(o,e).join(".");return n+s}function Ci(r){let e=[],t=0,n=r.length;for(;t=55296&&o<=56319&&t{"use strict";au="-",Nh=/^xn--/,_h=/[^\0-\x7E]/,Bh=/[\x2E\u3002\uFF0E\uFF61]/g,$h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Ei=36-1,Pt=Math.floor,Si=String.fromCharCode;uu=r=>String.fromCodePoint(...r),zh=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36},su=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},cu=function(r,e,t){let n=0;for(r=t?Pt(r/700):r>>1,r+=Pt(r/e);r>Ei*26>>1;n+=36)r=Pt(r/Ei);return Pt(n+(Ei+1)*r/(r+38))},Ai=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(au);i<0&&(i=0);for(let a=0;a=128&&er("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a=t&&er("invalid-input");let d=zh(r.charCodeAt(a++));(d>=36||d>Pt((2147483647-n)/c))&&er("overflow"),n+=d*c;let h=f<=s?1:f>=s+26?26:f-s;if(dPt(2147483647/m)&&er("overflow"),c*=m}let u=e.length+1;s=cu(n-l,u,l==0),Pt(n/u)>2147483647-o&&er("overflow"),o+=Pt(n/u),n%=u,e.splice(n++,0,o)}return String.fromCodePoint(...e)},ki=function(r){let e=[];r=Ci(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(Si(l));let i=e.length,a=i;for(i&&e.push(au);a=n&&cPt((2147483647-o)/u)&&er("overflow"),o+=(l-n)*u,n=l;for(let c of r)if(c2147483647&&er("overflow"),c==n){let f=o;for(let d=36;;d+=36){let h=d<=s?1:d>=s+26?26:d-s;if(f{"use strict";mu.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 yu=ie((av,vu)=>{"use strict";vu.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"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","text_collapse"]}}}});var xu=ie((lv,bu)=>{"use strict";bu.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"]},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","text_collapse"]}}}});var Cu=ie((uv,Su)=>{"use strict";var Br=Ne(),qh=sa(),Vh=la(),Gh=Oa(),Wh=gl(),Yh=Zl(),Kh=ou(),tr=ei(),wu=(pu(),ud(hu)),Xh={default:gu(),zero:yu(),commonmark:xu()},Zh=/^(vbscript|javascript|file|data):/,Qh=/^data:image\/(gif|png|jpeg|webp);/;function Jh(r){var e=r.trim().toLowerCase();return Zh.test(e)?!!Qh.test(e):!0}var Eu=["http:","https:","mailto:"];function ep(r){var e=tr.parse(r,!0);if(e.hostname&&(!e.protocol||Eu.indexOf(e.protocol)>=0))try{e.hostname=wu.toASCII(e.hostname)}catch{}return tr.encode(tr.format(e))}function tp(r){var e=tr.parse(r,!0);if(e.hostname&&(!e.protocol||Eu.indexOf(e.protocol)>=0))try{e.hostname=wu.toUnicode(e.hostname)}catch{}return tr.decode(tr.format(e),tr.decode.defaultChars+"%")}function Et(r,e){if(!(this instanceof Et))return new Et(r,e);e||Br.isString(r)||(e=r||{},r="default"),this.inline=new Yh,this.block=new Wh,this.core=new Gh,this.renderer=new Vh,this.linkify=new Kh,this.validateLink=Jh,this.normalizeLink=ep,this.normalizeLinkText=tp,this.utils=Br,this.helpers=Br.assign({},qh),this.options={},this.configure(r),e&&this.set(e)}Et.prototype.set=function(r){return Br.assign(this.options,r),this};Et.prototype.configure=function(r){var e=this,t;if(Br.isString(r)&&(t=r,r=Xh[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};Et.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};Et.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};Et.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};Et.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};Et.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};Et.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};Et.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};Su.exports=Et});var ku=ie((cv,Au)=>{"use strict";Au.exports=Cu()});var Fu=ie((dv,Lu)=>{var Ti=!0,Iu=!1,Du=!1;Lu.exports=function(r,e){e&&(Ti=!e.enabled,Iu=!!e.label,Du=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o=0;n--)if(r[n].level===t)return n;return-1}function np(r,e){return up(r[e])&&cp(r[e-1])&&dp(r[e-2])&&fp(r[e])}function ip(r,e){if(r.children.unshift(op(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),Iu)if(Du){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(lp(r.content,t,e))}else r.children.unshift(sp(e)),r.children.push(ap(e))}function op(r,e){var t=new e("html_inline","",0),n=Ti?' disabled="" ':"";return r.content.indexOf("[ ] ")===0?t.content='':(r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0)&&(t.content=''),t}function sp(r){var e=new r("html_inline","",0);return e.content="",e}function lp(r,e,t){var n=new t("html_inline","",0);return n.content='",n.attrs=[{for:e}],n}function up(r){return r.type==="inline"}function cp(r){return r.type==="paragraph_open"}function dp(r){return r.type==="list_item_open"}function fp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var Yu=ie((Ur,Fi)=>{(function(r,e){typeof Ur=="object"&&typeof Fi=="object"?Fi.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Ur=="object"?Ur.ClipboardJS=e():r.ClipboardJS=e()})(Ur,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return N}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),u=s.n(l);function c(S){try{return document.execCommand(S)}catch{return}}var f=function(S){return S=u()(S),c("cut"),S},d=function(S){var M,L,R,O=1"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 L,R=D(S);return L=M?(L=D(this).constructor,Reflect.construct(R,arguments,L)):R.apply(this,arguments),R=this,!(L=L)||v(L)!=="object"&&typeof L!="function"?function(O){if(O!==void 0)return O;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(R):L}}function D(S){return(D=Object.setPrototypeOf?Object.getPrototypeOf:function(M){return M.__proto__||Object.getPrototypeOf(M)})(S)}function I(S,M){if(S="data-clipboard-".concat(S),M.hasAttribute(S))return M.getAttribute(S)}var N=function(){(function(F,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");F.prototype=Object.create(_&&_.prototype,{constructor:{value:F,writable:!0,configurable:!0}}),_&&w(F,_)})(O,i());var S,M,L,R=x(O);function O(F,_){var j;return function(H){if(!(H instanceof O))throw new TypeError("Cannot call a class as a function")}(this),(j=R.call(this)).resolveOptions(_),j.listenClick(F),j}return S=O,L=[{key:"copy",value:function(F){var _=1"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,d){var h=function(m,v,y,w){return function(x){x.delegateTarget=i(x.target,v),x.delegateTarget&&w.call(m,x)}}.apply(this,arguments);return l.addEventListener(c,h,d),{destroy:function(){l.removeEventListener(c,h,d)}}}n.exports=function(l,u,c,f,d){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(h){return a(h,u,c,f,d)}))}},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 v=u,y=c,(m=l).addEventListener(v,y),{destroy:function(){m.removeEventListener(v,y)}};if(i.nodeList(l))return f=l,d=u,h=c,Array.prototype.forEach.call(f,function(w){w.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(f,function(w){w.removeEventListener(d,h)})}};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,d,h,m,v,y}},817:function(n){n.exports=function(o){var s,i=o.nodeName==="SELECT"?(o.focus(),o.value):o.nodeName==="INPUT"||o.nodeName==="TEXTAREA"?((s=o.hasAttribute("readonly"))||o.setAttribute("readonly",""),o.select(),o.setSelectionRange(0,o.value.length),s||o.removeAttribute("readonly"),o.value):(o.hasAttribute("contenteditable")&&o.focus(),i=window.getSelection(),(s=document.createRange()).selectNodeContents(o),i.removeAllRanges(),i.addRange(s),i.toString());return i}},279:function(n){function o(){}o.prototype={on:function(s,i,a){var l=this.e||(this.e={});return(l[s]||(l[s]=[])).push({fn:i,ctx:a}),this},once:function(s,i,a){var l=this;function 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")return this;let t=wr[r];for(let n=0;n"u"&&(wr[r]=[]),wr[r].push(e)}function fd(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function hd(r){if(!!r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(` -`);Hr("error",e)}}var Bi={emit:Hr,emitPublic:fd,listen:dd,success:r=>Hr("success",r),error:r=>Hr("error",r),showValidationErrors:hd};async function pd(r,e={}){return $i(r,{method:"GET",params:e})}async function md(r,e=null){return qr("POST",r,e)}async function gd(r,e=null){return qr("PUT",r,e)}async function vd(r,e=null){return qr("PATCH",r,e)}async function yd(r,e=null){return qr("DELETE",r,e)}async function qr(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"),$i(e,n)}async function $i(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 bd(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 bd(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 Ui={get:pd,post:md,put:gd,patch:vd,delete:yd};var zi=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}},ji=zi;function Vr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Gr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Ue(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 Wr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function We(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function Hi(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 Er(r){r.innerHTML='
'}function qi(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Sr(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 Cr(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 Gi(r){return r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Wi(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var Yi=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)),We(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.components.init(e)}setClonedInputNames(e){let t=Wi(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},Ki=Yi;var Xi=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Ue(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})}},Zi=Xi;var Qi=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}Wr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Ue(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}},Ji=Qi;var eo=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"),Er(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")}},to=eo;var ro=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")}},no=ro;var Mn={},io=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)),We(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),We(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(Mn[o])return Mn[o];let s=await window.$http.get(this.url,n);return Mn[o]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`
  • `).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()}},oo=io;var so=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.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))}},ao=so;function lo(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 Ft(r){for(var e=1;e=0)&&(t[o]=r[o]);return t}function Ed(r,e){if(r==null)return{};var t=wd(r,e),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(o=0;o=0)&&(!Object.prototype.propertyIsEnumerable.call(r,n)||(t[n]=r[n]))}return t}var Sd="1.14.0";function $t(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var zt=$t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Or=$t(/Edge/i),uo=$t(/firefox/i),Ir=$t(/safari/i)&&!$t(/chrome/i)&&!$t(/android/i),yo=$t(/iP(ad|od|hone)/i),Cd=$t(/chrome/i)&&$t(/android/i),bo={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!zt&&bo)}function Le(r,e,t){r.removeEventListener(e,t,!zt&&bo)}function nn(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 Ad(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Dt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&nn(r,e):nn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Ad(r))}return null}var co=/\s+/g;function pt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(co," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(co," ")}}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 ur(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 xo(r,e,t){if(r){var n=r.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o=s:i=o<=s,!i)return n;if(n===Lt())break;n=Wt(n,!1)}return!1}function cr(r,e,t,n){for(var o=0,s=0,i=r.children;s2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Ed(n,Od);Pr.pluginEvent.bind(ve)(e,t,Ft({dragEl:ee,parentEl:Xe,ghostEl:we,rootEl:qe,nextEl:Qt,lastDownEl:Jr,cloneEl:Ze,cloneHidden:Gt,dragStarted:Ar,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:lr,oldDraggableIndex:Lr,newIndex:mt,newDraggableIndex:Vt,hideGhostForTarget:To,unhideGhostForTarget:Io,cloneNowHidden:function(){Gt=!0},cloneNowShown:function(){Gt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){Rd(Ft({putSortable:it,cloneEl:Ze,targetEl:ee,rootEl:qe,oldIndex:lr,oldDraggableIndex:Lr,newIndex:mt,newDraggableIndex:Vt},r))}var ee,Xe,we,qe,Qt,Jr,Ze,Gt,lr,mt,Lr,Vt,Yr,it,ar=!1,on=!1,sn=[],Xt,Ct,Bn,$n,po,mo,Ar,sr,Fr,Rr=!1,Kr=!1,en,lt,Un=[],Vn=!1,an=[],un=typeof document<"u",Xr=yo,go=Or||zt?"cssFloat":"float",Pd=un&&!Cd&&!yo&&"draggable"in document.createElement("div"),Co=function(){if(!!un){if(zt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Ao=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=cr(e,0,t),i=cr(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[go]==="none"||i&&n[go]==="none"&&u+c>o)?"vertical":"horizontal"},Md=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},Nd=function(e,t){var n;return sn.some(function(o){var s=o[gt].options.emptyInsertThreshold;if(!(!s||Kn(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},ko=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 d=(i?a:l).options.group.name;return s===!0||typeof s=="string"&&s===d||s.join&&s.indexOf(d)>-1}}var n={},o=e.group;(!o||Qr(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},To=function(){!Co&&we&&ge(we,"display","none")},Io=function(){!Co&&we&&ge(we,"display","")};un&&document.addEventListener("click",function(r){if(on)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),on=!1,!1},!0);var Zt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=Nd(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[gt]._onDragOver(n)}}},_d=function(e){ee&&ee.parentNode[gt]._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=Ut({},e),r[gt]=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 Ao(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&&!Ir,emptyInsertThreshold:5};Pr.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);ko(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:Pd,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)),sn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Ut(this,Dd())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(sr=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(Vd(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Ir&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Dt(l,o.draggable,n,!1),!(l&&l.animated)&&Jr!==l)){if(lr=xt(l),Lr=xt(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=Dt(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&&!Dt(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(qe=s,ee=n,Xe=ee.parentNode,Qt=ee.nextSibling,Jr=n,Yr=i.group,ve.dragged=ee,Xt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},po=Xt.clientX-u.left,mo=Xt.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(),!uo&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),pt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){xo(ee,c.trim(),zn)}),Me(a,"dragover",Zt),Me(a,"mousemove",Zt),Me(a,"touchmove",Zt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),uo&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Or||zt))){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&&zn(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(qe,"dragstart",this._onDragStart));try{document.selection?tn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ar=!1,qe&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",_d);var n=this.options;!e&&pt(ee,n.dragClass,!1),pt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Ct){this._lastX=Ct.clientX,this._lastY=Ct.clientY,To();for(var e=document.elementFromPoint(Ct.clientX,Ct.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Ct.clientX,Ct.clientY),e!==t);)t=e;if(ee.parentNode[gt]._isOutsideThisEl(e),t)do{if(t[gt]){var n=void 0;if(n=t[gt]._onDragOver({clientX:Ct.clientX,clientY:Ct.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Io()}},_onTouchMove:function(e){if(Xt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&ur(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=Xr&<&&ho(lt),c=(s.clientX-Xt.clientX+o.x)/(a||1)+(u?u[0]-Un[0]:0)/(a||1),f=(s.clientY-Xt.clientY+o.y)/(l||1)+(u?u[1]-Un[1]:0)/(l||1);if(!ve.active&&!ar){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))=0&&(ct({rootEl:Xe,name:"add",toEl:Xe,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Xe,originalEvent:e}),ct({rootEl:Xe,name:"sort",toEl:Xe,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Xe,originalEvent:e})),it&&it.save()):mt!==lr&&mt>=0&&(ct({sortable:this,name:"update",toEl:Xe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Xe,originalEvent:e})),ve.active&&((mt==null||mt===-1)&&(mt=lr,Vt=Lr),ct({sortable:this,name:"end",toEl:Xe,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),qe=ee=Xe=we=Qt=Ze=Jr=Gt=Xt=Ct=Ar=mt=Vt=lr=Lr=sr=Fr=it=Yr=ve.dragged=ve.ghost=ve.clone=ve.active=null,an.forEach(function(e){e.checked=!0}),an.length=Bn=$n=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),Bd(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;on.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 jd(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,d=!1;if(!i){if(a&&enc+u*s/2:lf-en)return-Fr}else if(l>c+u*(1-o)/2&&lf-u*s/2)?l>c+u/2?1:-1:0}function Hd(r){return xt(ee){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=Lo[a];t&&n.includes(a)&&(l=function(u,c){return 0-Lo[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 dr(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{t&&t()})}function dn(r,e=400,t=null){hn(r),fn(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function fr(r,e=400){hn(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={height:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[o,"0px"],paddingBottom:[s,"0px"]};fn(r,i,e,()=>{r.style.display="none"})}function hr(r,e=400){hn(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={height:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",o],paddingBottom:["0px",s]};fn(r,i,e)}function fn(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),cn.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),cn.set(r,s)},15)}function hn(r){cn.has(r)&&cn.get(r)()}var Po=class{constructor(e){this.elem=e,this.isOpen=e.classList.contains("open"),e.addEventListener("click",this.click.bind(this))}open(){let e=this.elem.parentNode.querySelector(".inset-list");this.elem.classList.add("open"),this.elem.setAttribute("aria-expanded","true"),hr(e,240)}close(){let e=this.elem.parentNode.querySelector(".inset-list");this.elem.classList.remove("open"),this.elem.setAttribute("aria-expanded","false"),fr(e,240)}click(e){e.preventDefault(),this.isOpen?this.close():this.open(),this.isOpen=!this.isOpen}},Mo=Po;var No=class{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageLinks=this.$manyRefs.languageLink,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),Ue(this.languageLinks,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.updateEditorMode(t)}),Wr(this.languageInput,e=>this.save()),Ue(this.saveButton,e=>this.save()),We(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}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(),this.updateEditorMode(t),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())}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`
  • `}).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)}},_o=No;var Bo=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},$o=Bo;var Uo=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"),hr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),fr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},zo=Uo;var jo=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)}},Ho=jo;var qo=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)}},Vo=qo;var Go=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"),this.moveMenu&&(this.rect=this.menu.getBoundingClientRect(),this.body.appendChild(this.menu),this.menu.style.position="fixed",this.direction==="right"?this.menu.style.right=`${this.rect.right-this.rect.width}px`:this.menu.style.left=`${this.rect.left}px`,this.menu.style.top=`${this.rect.top}px`,this.menu.style.width=`${this.rect.width}px`),this.menu.addEventListener("mouseleave",this.hide.bind(this)),window.addEventListener("click",o=>{this.menu.contains(o.target)||this.hide()});let t=this.menu.querySelector("input");t!==null&&t.focus(),this.showing=!0;let n=new Event("show");this.container.dispatchEvent(n),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.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.top="",this.menu.style.width="",this.container.appendChild(this.menu)),this.showing=!1}getFocusable(){return Array.from(this.menu.querySelectorAll("[tabindex],[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()}),Ue(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())})}},Wo=Go;var Yo=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=Sr(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));this.listContainerElem.innerHTML=t.data}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"}},Ko=Yo;var Zo=jr(Xo());var Qo=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 Zo.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),dn(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)}},Jo=Qo;var es=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{e.preventDefault(),this.runSearch()}),Ue(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=""}},os=is;var ss=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())}),We(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}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}},as=ss;var ls=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,this.searchInput=this.$refs.searchInput,window.EntitySelectorPopup=this,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.onSelectionConfirm.bind(this))}show(e){this.callback=e,this.elem.components.popup.show(),this.searchInput.focus()}hide(){this.elem.components.popup.hide()}onSelectButtonClick(){this.hide(),this.selection!==null&&this.callback&&this.callback(this.selection)}onSelectionConfirm(e){this.hide(),this.callback&&e&&this.callback(e)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}},us=ls;var cs=class{setup(){this.container=this.$el,this.name=this.$opts.name,Ue(this.$el,()=>{this.$emit(this.name,this.$opts)})}},ds=cs;var fs=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){hr(e,200)}close(e){fr(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"})}},hs=fs;var ps=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)}},ms=ps;var gs=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"}},vs=gs;var ys=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(){Ue(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()}),Ue(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),We(this.listContainer,".load-more","click",async e=>{Er(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),Ue(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),We(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.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),qi(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(){Er(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)}},bs=ys;var xs=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")}},ws=xs;var Es=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()}},Ss=Es;var Nu=jr(ku()),_u=jr(Fu());var Ru=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}},$r=Ru;var jt=null,Li,Ii,Di;function hp(r,e,t){Ii=e,Di=t,jt=document.createElement("iframe"),jt.setAttribute("frameborder","0"),window.addEventListener("message",Ou),jt.setAttribute("src",r),jt.setAttribute("class","fullscreen"),jt.style.backgroundColor="#FFFFFF",document.body.appendChild(jt),Li=new URL(r).origin}function pp(){Pu()}function Ou(r){if(!r.data||r.data.length<1||r.origin!==Li)return;let e=JSON.parse(r.data);e.event==="init"?vp():e.event==="exit"?Pu():e.event==="save"?gp(e):e.event==="export"&&mp(e)}function mp(r){Di&&Di(r.data)}function gp(r){Mu({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function vp(){!Ii||Ii().then(r=>{Mu({action:"load",autosave:1,xml:r})})}function Pu(){window.removeEventListener("message",Ou),jt&&document.body.removeChild(jt)}function Mu(r){jt.contentWindow.postMessage(JSON.stringify(r),Li)}async function yp(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function bp(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var vt={show:hp,close:pp,upload:yp,load:bp};var Bu=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 Nu.default({html:!0}),this.markdown.use(_u.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=Sr(()=>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),this.displayDoc.body.className="page-content",this.displayDoc.body.innerHTML=t,this.loadStylesIntoDisplay()}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=`![${d.getSelection()}](http://)`,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=>{f()},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('

    ',"

    ")},e.setOption("extraKeys",o),e.on("change",(d,h)=>{this.updateAndRender()});let s=Sr(d=>{let h=d.getScrollInfo();if(h.top+h.clientHeight===h.height){this.onMarkdownScroll(-1);return}let v=d.lineAtHeight(h.top,"local"),y=d.getRange({line:0,ch:null},{line:v,ch:null}),D=new DOMParser().parseFromString(this.markdown.render(y),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(D.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,h)=>{let m=new $r(h.clipboardData||h.dataTransfer);if(!m.hasItems()||m.containsTabularData())return;let v=m.getImages();for(let y of v)c(y)}),e.on("drop",(d,h)=>{let m=h.dataTransfer.getData("bookstack/template");if(m){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.preventDefault(),window.$http.get(`/templates/${m}`).then(w=>{let x=w.data.markdown||w.data.html;d.replaceSelection(x)})}let v=new $r(h.dataTransfer);if(v.hasItems()&&v.getImages().length>0){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.stopPropagation(),h.preventDefault();let w=v.getImages();for(let x of w)c(x)}});function i(d,h){let m=e.getValue(),v=e.listSelections();e.setValue(m.replace(d,h)),e.setSelections(v)}function a(d){let h=e.getCursor(),m=e.getLine(h.line),v=m.length,y=m.split(" ")[0];if(y===d){m=m.replace(`${d} `,""),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch-(d.length+1)});return}let w=/^[#>`]/.test(y),x=0;w?(x=d.length-y.length,m=m.replace(y,d).trim()):d!==""&&(x=d.length+1,m=d+" "+m),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch+x})}function l(d,h){let m=e.getCursor(),v=e.getLine(m.line),y=v.length,w=v;v.indexOf(d)===0&&v.slice(-h.length)===h?w=v.slice(d.length,v.length-h.length):w=`${d}${v}${h}`,e.replaceRange(w,{line:m.line,ch:0},{line:m.line,ch:y}),e.setCursor({line:m.line,ch:m.ch+d.length})}function u(d,h){let m=e.getSelection();if(m==="")return l(d,h);let v=m,y=0,w=0;m.indexOf(d)===0&&m.slice(-h.length)===h?(v=m.slice(d.length,m.length-h.length),w=-(h.length+d.length)):(v=`${d}${m}${h}`,w=d.length+h.length);let x=e.listSelections()[0];e.replaceSelection(v);let D=x.head.ch<=x.anchor.ch;x.head.ch+=D?y:w,x.anchor.ch+=D?w:y,e.setSelections([x])}function c(d){if(d===null||d.type.indexOf("image")!==0)return;let h="png";if(d.name){let N=d.name.match(/\.(.+)$/);N.length>1&&(h=N[1])}let m="image-"+Math.random().toString(16).slice(2),v=window.baseUrl(`/loading.gif#upload${m}`),y=e.getSelection(),w=`![${y}](${v})`,x=e.getCursor();e.replaceSelection(w),e.setCursor({line:x.line,ch:x.ch+y.length+3});let D="image-"+Date.now()+"."+h,I=new FormData;I.append("file",d,D),I.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",I).then(N=>{let S=`[![${y}](${N.data.thumbs.display})](${N.data.url})`;i(w,S)}).catch(N=>{window.$events.emit("error",t.imageUploadErrorText),i(w,y),console.log(N)})}function f(){let d=e.getCursor("from"),h=e.getSelection()||"",m=`[${h}]()`;e.focus(),e.replaceSelection(m);let v=h===""?-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="[!["+(o||t.name)+"]("+n+")]("+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");vt.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),vt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`
    `;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");vt.show(t,()=>vt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`
    `,u=this.cm.getValue().split(` +`);Hr("error",e)}}var Bi={emit:Hr,emitPublic:fd,listen:dd,success:r=>Hr("success",r),error:r=>Hr("error",r),showValidationErrors:hd};async function pd(r,e={}){return $i(r,{method:"GET",params:e})}async function md(r,e=null){return qr("POST",r,e)}async function gd(r,e=null){return qr("PUT",r,e)}async function vd(r,e=null){return qr("PATCH",r,e)}async function yd(r,e=null){return qr("DELETE",r,e)}async function qr(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"),$i(e,n)}async function $i(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 bd(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 bd(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 Ui={get:pd,post:md,put:gd,patch:vd,delete:yd};var zi=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}},ji=zi;function Vr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Gr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Ue(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 Wr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function We(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function Hi(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 Er(r){r.innerHTML='
    '}function qi(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Sr(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 Cr(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 Gi(r){return r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Wi(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var Yi=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)),We(this.$el,this.removeSelector,"click",e=>{e.target.closest(this.rowSelector).remove()})}add(){let e=this.modelRow.cloneNode(!0);e.classList.remove("hidden"),this.setClonedInputNames(e),this.modelRow.parentNode.insertBefore(e,this.modelRow),window.components.init(e)}setClonedInputNames(e){let t=Wi(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},Ki=Yi;var Xi=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Ue(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})}},Zi=Xi;var Qi=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}Wr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Ue(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}},Ji=Qi;var eo=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"),Er(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")}},to=eo;var ro=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")}},no=ro;var Mn={},io=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)),We(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),We(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(Mn[o])return Mn[o];let s=await window.$http.get(this.url,n);return Mn[o]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`
  • `).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()}},oo=io;var so=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.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))}},ao=so;function lo(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 Ft(r){for(var e=1;e=0)&&(t[o]=r[o]);return t}function Ed(r,e){if(r==null)return{};var t=wd(r,e),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(o=0;o=0)&&(!Object.prototype.propertyIsEnumerable.call(r,n)||(t[n]=r[n]))}return t}var Sd="1.14.0";function $t(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var zt=$t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Or=$t(/Edge/i),uo=$t(/firefox/i),Ir=$t(/safari/i)&&!$t(/chrome/i)&&!$t(/android/i),yo=$t(/iP(ad|od|hone)/i),Cd=$t(/chrome/i)&&$t(/android/i),bo={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!zt&&bo)}function Le(r,e,t){r.removeEventListener(e,t,!zt&&bo)}function nn(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 Ad(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Dt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&nn(r,e):nn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Ad(r))}return null}var co=/\s+/g;function pt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(co," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(co," ")}}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 ur(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 xo(r,e,t){if(r){var n=r.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o=s:i=o<=s,!i)return n;if(n===Lt())break;n=Wt(n,!1)}return!1}function cr(r,e,t,n){for(var o=0,s=0,i=r.children;s2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Ed(n,Od);Pr.pluginEvent.bind(ve)(e,t,Ft({dragEl:ee,parentEl:Xe,ghostEl:we,rootEl:qe,nextEl:Qt,lastDownEl:Jr,cloneEl:Ze,cloneHidden:Gt,dragStarted:Ar,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:lr,oldDraggableIndex:Lr,newIndex:mt,newDraggableIndex:Vt,hideGhostForTarget:To,unhideGhostForTarget:Io,cloneNowHidden:function(){Gt=!0},cloneNowShown:function(){Gt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){Rd(Ft({putSortable:it,cloneEl:Ze,targetEl:ee,rootEl:qe,oldIndex:lr,oldDraggableIndex:Lr,newIndex:mt,newDraggableIndex:Vt},r))}var ee,Xe,we,qe,Qt,Jr,Ze,Gt,lr,mt,Lr,Vt,Yr,it,ar=!1,on=!1,sn=[],Xt,Ct,Bn,$n,po,mo,Ar,sr,Fr,Rr=!1,Kr=!1,en,lt,Un=[],Vn=!1,an=[],un=typeof document<"u",Xr=yo,go=Or||zt?"cssFloat":"float",Pd=un&&!Cd&&!yo&&"draggable"in document.createElement("div"),Co=function(){if(!!un){if(zt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Ao=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=cr(e,0,t),i=cr(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[go]==="none"||i&&n[go]==="none"&&u+c>o)?"vertical":"horizontal"},Md=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},Nd=function(e,t){var n;return sn.some(function(o){var s=o[gt].options.emptyInsertThreshold;if(!(!s||Kn(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},ko=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 d=(i?a:l).options.group.name;return s===!0||typeof s=="string"&&s===d||s.join&&s.indexOf(d)>-1}}var n={},o=e.group;(!o||Qr(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},To=function(){!Co&&we&&ge(we,"display","none")},Io=function(){!Co&&we&&ge(we,"display","")};un&&document.addEventListener("click",function(r){if(on)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),on=!1,!1},!0);var Zt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=Nd(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[gt]._onDragOver(n)}}},_d=function(e){ee&&ee.parentNode[gt]._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=Ut({},e),r[gt]=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 Ao(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&&!Ir,emptyInsertThreshold:5};Pr.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);ko(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:Pd,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)),sn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Ut(this,Dd())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(sr=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(Vd(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Ir&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Dt(l,o.draggable,n,!1),!(l&&l.animated)&&Jr!==l)){if(lr=xt(l),Lr=xt(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=Dt(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&&!Dt(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(qe=s,ee=n,Xe=ee.parentNode,Qt=ee.nextSibling,Jr=n,Yr=i.group,ve.dragged=ee,Xt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},po=Xt.clientX-u.left,mo=Xt.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(),!uo&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),pt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){xo(ee,c.trim(),zn)}),Me(a,"dragover",Zt),Me(a,"mousemove",Zt),Me(a,"touchmove",Zt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),uo&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Or||zt))){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&&zn(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(qe,"dragstart",this._onDragStart));try{document.selection?tn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ar=!1,qe&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",_d);var n=this.options;!e&&pt(ee,n.dragClass,!1),pt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Ct){this._lastX=Ct.clientX,this._lastY=Ct.clientY,To();for(var e=document.elementFromPoint(Ct.clientX,Ct.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Ct.clientX,Ct.clientY),e!==t);)t=e;if(ee.parentNode[gt]._isOutsideThisEl(e),t)do{if(t[gt]){var n=void 0;if(n=t[gt]._onDragOver({clientX:Ct.clientX,clientY:Ct.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Io()}},_onTouchMove:function(e){if(Xt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&ur(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=Xr&<&&ho(lt),c=(s.clientX-Xt.clientX+o.x)/(a||1)+(u?u[0]-Un[0]:0)/(a||1),f=(s.clientY-Xt.clientY+o.y)/(l||1)+(u?u[1]-Un[1]:0)/(l||1);if(!ve.active&&!ar){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))=0&&(ct({rootEl:Xe,name:"add",toEl:Xe,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Xe,originalEvent:e}),ct({rootEl:Xe,name:"sort",toEl:Xe,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Xe,originalEvent:e})),it&&it.save()):mt!==lr&&mt>=0&&(ct({sortable:this,name:"update",toEl:Xe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Xe,originalEvent:e})),ve.active&&((mt==null||mt===-1)&&(mt=lr,Vt=Lr),ct({sortable:this,name:"end",toEl:Xe,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),qe=ee=Xe=we=Qt=Ze=Jr=Gt=Xt=Ct=Ar=mt=Vt=lr=Lr=sr=Fr=it=Yr=ve.dragged=ve.ghost=ve.clone=ve.active=null,an.forEach(function(e){e.checked=!0}),an.length=Bn=$n=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),Bd(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;on.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 jd(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,d=!1;if(!i){if(a&&enc+u*s/2:lf-en)return-Fr}else if(l>c+u*(1-o)/2&&lf-u*s/2)?l>c+u/2?1:-1:0}function Hd(r){return xt(ee){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=Lo[a];t&&n.includes(a)&&(l=function(u,c){return 0-Lo[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 dr(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{t&&t()})}function dn(r,e=400,t=null){hn(r),fn(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function fr(r,e=400){hn(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={height:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[o,"0px"],paddingBottom:[s,"0px"]};fn(r,i,e,()=>{r.style.display="none"})}function hr(r,e=400){hn(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={height:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",o],paddingBottom:["0px",s]};fn(r,i,e)}function fn(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),cn.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),cn.set(r,s)},15)}function hn(r){cn.has(r)&&cn.get(r)()}var Po=class{constructor(e){this.elem=e,this.isOpen=e.classList.contains("open"),e.addEventListener("click",this.click.bind(this))}open(){let e=this.elem.parentNode.querySelector(".inset-list");this.elem.classList.add("open"),this.elem.setAttribute("aria-expanded","true"),hr(e,240)}close(){let e=this.elem.parentNode.querySelector(".inset-list");this.elem.classList.remove("open"),this.elem.setAttribute("aria-expanded","false"),fr(e,240)}click(e){e.preventDefault(),this.isOpen?this.close():this.open(),this.isOpen=!this.isOpen}},Mo=Po;var No=class{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageLinks=this.$manyRefs.languageLink,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),Ue(this.languageLinks,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.updateEditorMode(t)}),Wr(this.languageInput,e=>this.save()),Ue(this.saveButton,e=>this.save()),We(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}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.updateEditorMode(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())}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`
  • `}).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)}},_o=No;var Bo=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},$o=Bo;var Uo=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"),hr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),fr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},zo=Uo;var jo=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)}},Ho=jo;var qo=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)}},Vo=qo;var Go=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"),this.moveMenu&&(this.rect=this.menu.getBoundingClientRect(),this.body.appendChild(this.menu),this.menu.style.position="fixed",this.direction==="right"?this.menu.style.right=`${this.rect.right-this.rect.width}px`:this.menu.style.left=`${this.rect.left}px`,this.menu.style.top=`${this.rect.top}px`,this.menu.style.width=`${this.rect.width}px`),this.menu.addEventListener("mouseleave",this.hide.bind(this)),window.addEventListener("click",o=>{this.menu.contains(o.target)||this.hide()});let t=this.menu.querySelector("input");t!==null&&t.focus(),this.showing=!0;let n=new Event("show");this.container.dispatchEvent(n),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.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.top="",this.menu.style.width="",this.container.appendChild(this.menu)),this.showing=!1}getFocusable(){return Array.from(this.menu.querySelectorAll("[tabindex],[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()}),Ue(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())})}},Wo=Go;var Yo=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=Sr(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));this.listContainerElem.innerHTML=t.data}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"}},Ko=Yo;var Zo=jr(Xo());var Qo=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 Zo.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),dn(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)}},Jo=Qo;var es=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{e.preventDefault(),this.runSearch()}),Ue(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=""}},os=is;var ss=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())}),We(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}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}},as=ss;var ls=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,this.searchInput=this.$refs.searchInput,window.EntitySelectorPopup=this,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.onSelectionConfirm.bind(this))}show(e){this.callback=e,this.elem.components.popup.show(),this.searchInput.focus()}hide(){this.elem.components.popup.hide()}onSelectButtonClick(){this.hide(),this.selection!==null&&this.callback&&this.callback(this.selection)}onSelectionConfirm(e){this.hide(),this.callback&&e&&this.callback(e)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}},us=ls;var cs=class{setup(){this.container=this.$el,this.name=this.$opts.name,Ue(this.$el,()=>{this.$emit(this.name,this.$opts)})}},ds=cs;var fs=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){hr(e,200)}close(e){fr(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"})}},hs=fs;var ps=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)}},ms=ps;var gs=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"}},vs=gs;var ys=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(){Ue(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()}),Ue(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),We(this.listContainer,".load-more","click",async e=>{Er(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),Ue(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),We(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.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),qi(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(){Er(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)}},bs=ys;var xs=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")}},ws=xs;var Es=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()}},Ss=Es;var Nu=jr(ku()),_u=jr(Fu());var Ru=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}},$r=Ru;var jt=null,Li,Ii,Di;function hp(r,e,t){Ii=e,Di=t,jt=document.createElement("iframe"),jt.setAttribute("frameborder","0"),window.addEventListener("message",Ou),jt.setAttribute("src",r),jt.setAttribute("class","fullscreen"),jt.style.backgroundColor="#FFFFFF",document.body.appendChild(jt),Li=new URL(r).origin}function pp(){Pu()}function Ou(r){if(!r.data||r.data.length<1||r.origin!==Li)return;let e=JSON.parse(r.data);e.event==="init"?vp():e.event==="exit"?Pu():e.event==="save"?gp(e):e.event==="export"&&mp(e)}function mp(r){Di&&Di(r.data)}function gp(r){Mu({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function vp(){!Ii||Ii().then(r=>{Mu({action:"load",autosave:1,xml:r})})}function Pu(){window.removeEventListener("message",Ou),jt&&document.body.removeChild(jt)}function Mu(r){jt.contentWindow.postMessage(JSON.stringify(r),Li)}async function yp(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function bp(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var vt={show:hp,close:pp,upload:yp,load:bp};var Bu=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 Nu.default({html:!0}),this.markdown.use(_u.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=Sr(()=>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),this.displayDoc.body.className="page-content",this.displayDoc.body.innerHTML=t,this.loadStylesIntoDisplay()}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=`![${d.getSelection()}](http://)`,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=>{f()},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('

    ',"

    ")},e.setOption("extraKeys",o),e.on("change",(d,h)=>{this.updateAndRender()});let s=Sr(d=>{let h=d.getScrollInfo();if(h.top+h.clientHeight===h.height){this.onMarkdownScroll(-1);return}let v=d.lineAtHeight(h.top,"local"),y=d.getRange({line:0,ch:null},{line:v,ch:null}),D=new DOMParser().parseFromString(this.markdown.render(y),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(D.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,h)=>{let m=new $r(h.clipboardData||h.dataTransfer);if(!m.hasItems()||m.containsTabularData())return;let v=m.getImages();for(let y of v)c(y)}),e.on("drop",(d,h)=>{let m=h.dataTransfer.getData("bookstack/template");if(m){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.preventDefault(),window.$http.get(`/templates/${m}`).then(w=>{let x=w.data.markdown||w.data.html;d.replaceSelection(x)})}let v=new $r(h.dataTransfer);if(v.hasItems()&&v.getImages().length>0){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.stopPropagation(),h.preventDefault();let w=v.getImages();for(let x of w)c(x)}});function i(d,h){let m=e.getValue(),v=e.listSelections();e.setValue(m.replace(d,h)),e.setSelections(v)}function a(d){let h=e.getCursor(),m=e.getLine(h.line),v=m.length,y=m.split(" ")[0];if(y===d){m=m.replace(`${d} `,""),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch-(d.length+1)});return}let w=/^[#>`]/.test(y),x=0;w?(x=d.length-y.length,m=m.replace(y,d).trim()):d!==""&&(x=d.length+1,m=d+" "+m),e.replaceRange(m,{line:h.line,ch:0},{line:h.line,ch:v}),e.setCursor({line:h.line,ch:h.ch+x})}function l(d,h){let m=e.getCursor(),v=e.getLine(m.line),y=v.length,w=v;v.indexOf(d)===0&&v.slice(-h.length)===h?w=v.slice(d.length,v.length-h.length):w=`${d}${v}${h}`,e.replaceRange(w,{line:m.line,ch:0},{line:m.line,ch:y}),e.setCursor({line:m.line,ch:m.ch+d.length})}function u(d,h){let m=e.getSelection();if(m==="")return l(d,h);let v=m,y=0,w=0;m.indexOf(d)===0&&m.slice(-h.length)===h?(v=m.slice(d.length,m.length-h.length),w=-(h.length+d.length)):(v=`${d}${m}${h}`,w=d.length+h.length);let x=e.listSelections()[0];e.replaceSelection(v);let D=x.head.ch<=x.anchor.ch;x.head.ch+=D?y:w,x.anchor.ch+=D?w:y,e.setSelections([x])}function c(d){if(d===null||d.type.indexOf("image")!==0)return;let h="png";if(d.name){let N=d.name.match(/\.(.+)$/);N.length>1&&(h=N[1])}let m="image-"+Math.random().toString(16).slice(2),v=window.baseUrl(`/loading.gif#upload${m}`),y=e.getSelection(),w=`![${y}](${v})`,x=e.getCursor();e.replaceSelection(w),e.setCursor({line:x.line,ch:x.ch+y.length+3});let D="image-"+Date.now()+"."+h,I=new FormData;I.append("file",d,D),I.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",I).then(N=>{let S=`[![${y}](${N.data.thumbs.display})](${N.data.url})`;i(w,S)}).catch(N=>{window.$events.emit("error",t.imageUploadErrorText),i(w,y),console.log(N)})}function f(){let d=e.getCursor("from"),h=e.getSelection()||"",m=`[${h}]()`;e.focus(),e.replaceSelection(m);let v=h===""?-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="[!["+(o||t.name)+"]("+n+")]("+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");vt.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),vt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`
    `;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");vt.show(t,()=>vt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`
    `,u=this.cm.getValue().split(` `).map(c=>c.indexOf(`drawio-diagram="${o}"`)!==-1?l:c).join(` `);this.cm.setValue(u),this.cm.setCursor(n),this.cm.focus(),vt.close()}).catch(a=>{this.handleDrawingUploadError(a)})})}handleDrawingUploadError(e){e.status===413?window.$events.emit("error",this.serverUploadLimitText):window.$events.emit("error",this.imageUploadErrorText),console.log(e)}actionFullScreen(){let e=this.elem.classList.contains("fullscreen");this.elem.classList.toggle("fullscreen",!e),document.body.classList.toggle("markdown-fullscreen",!e)}scrollToText(e){if(!e)return;let n=this.cm.getValue().split(/\r?\n/),o=n.findIndex(s=>s&&s.indexOf(e)!==-1);o!==-1&&(this.cm.scrollIntoView({line:o},200),this.cm.focus(),this.cm.setCursor({line:o,char:n[o].length}))}listenForBookStackEditorEvents(){function e({html:t,markdown:n}){return n||t}window.$events.listen("editor::replace",t=>{let n=e(t);this.cm.setValue(n)}),window.$events.listen("editor::append",t=>{let n=this.cm.getCursor("from"),o=e(t),s=this.cm.getValue()+` `+o;this.cm.setValue(s),this.cm.setCursor(n.line,n.ch)}),window.$events.listen("editor::prepend",t=>{let n=this.cm.getCursor("from"),o=e(t),s=o+` `+this.cm.getValue();this.cm.setValue(s);let i=o.split(` `).length;this.cm.setCursor(n.line+i,n.ch)}),window.$events.listen("editor::insert",t=>{let n=e(t);this.cm.replaceSelection(n)}),window.$events.listen("editor::focus",()=>{this.cm.focus()})}},$u=Bu;var Uu=class{constructor(e){this.elem=e,this.inviteOption=e.querySelector("input[name=send_invite]"),this.inviteOption&&(this.inviteOption.addEventListener("change",this.inviteOptionChange.bind(this)),this.inviteOptionChange())}inviteOptionChange(){let e=this.inviteOption.value==="true",t=this.elem.querySelectorAll("input[type=password]");for(let o of t)o.disabled=e;let n=this.elem.querySelector("#password-input-container");n&&(n.style.display=e?"none":"block")}},zu=Uu;var ju=class{constructor(e){this.elem=e,this.type=e.getAttribute("notification"),this.textElem=e.querySelector("span"),this.autohide=this.elem.hasAttribute("data-autohide"),this.elem.style.display="grid",window.$events.listen(this.type,t=>{this.show(t)}),e.addEventListener("click",this.hide.bind(this)),e.hasAttribute("data-show")&&setTimeout(()=>this.show(this.textElem.textContent),100),this.hideCleanup=this.hideCleanup.bind(this)}show(e=""){if(this.elem.removeEventListener("transitionend",this.hideCleanup),this.textElem.textContent=e,this.elem.style.display="grid",setTimeout(()=>{this.elem.classList.add("showing")},1),this.autohide){let t=e.split(" ").length,n=Math.max(2e3,1e3+250*t);setTimeout(this.hide.bind(this),n)}}hide(){this.elem.classList.remove("showing"),this.elem.addEventListener("transitionend",this.hideCleanup)}hideCleanup(){this.elem.style.display="none",this.elem.removeEventListener("transitionend",this.hideCleanup)}},Hu=ju;var qu=class{setup(){this.removeButton=this.$refs.remove,this.showButton=this.$refs.show,this.input=this.$refs.input,this.setupListeners()}setupListeners(){Ue(this.removeButton,()=>{this.input.value="",this.input.classList.add("hidden"),this.removeButton.classList.add("hidden"),this.showButton.classList.remove("hidden")}),Ue(this.showButton,()=>{this.input.classList.remove("hidden"),this.removeButton.classList.remove("hidden"),this.showButton.classList.add("hidden")})}},Vu=qu;var Gu=class{setup(){this.elem=this.$el,this.pageId=Number(this.$opts.pageId),this.container=this.$refs.commentContainer,this.formContainer=this.$refs.formContainer,this.commentCountBar=this.$refs.commentCountBar,this.addButtonContainer=this.$refs.addButtonContainer,this.replyToRow=this.$refs.replyToRow,this.updatedText=this.$opts.updatedText,this.deletedText=this.$opts.deletedText,this.createdText=this.$opts.createdText,this.countText=this.$opts.countText,this.editingComment=null,this.parentId=null,this.formContainer&&(this.form=this.formContainer.querySelector("form"),this.formInput=this.form.querySelector("textarea"),this.form.addEventListener("submit",this.saveComment.bind(this))),this.elem.addEventListener("click",this.handleAction.bind(this)),this.elem.addEventListener("submit",this.updateComment.bind(this))}handleAction(e){let t=e.target.closest("[action]");if(e.target.matches('a[href^="#"]')){let s=e.target.href.split("#")[1];Cr(document.querySelector("#"+s))}if(t===null)return;e.preventDefault();let n=t.getAttribute("action"),o=t.closest("[comment]");n==="edit"&&this.editComment(o),n==="closeUpdateForm"&&this.closeUpdateForm(),n==="delete"&&this.deleteComment(o),n==="addComment"&&this.showForm(),n==="hideForm"&&this.hideForm(),n==="reply"&&this.setReply(o),n==="remove-reply-to"&&this.removeReplyTo()}closeUpdateForm(){!this.editingComment||(this.editingComment.querySelector("[comment-content]").style.display="block",this.editingComment.querySelector("[comment-edit-container]").style.display="none")}editComment(e){this.hideForm(),this.editingComment&&this.closeUpdateForm(),e.querySelector("[comment-content]").style.display="none",e.querySelector("[comment-edit-container]").style.display="block";let t=e.querySelector("[comment-edit-container] textarea"),n=t.value.split(` `).length;t.style.height=n*20+40+"px",this.editingComment=e}updateComment(e){let t=e.target;e.preventDefault();let o={text:t.querySelector("textarea").value,parent_id:this.parentId||null};this.showLoading(t);let s=this.editingComment.getAttribute("comment");window.$http.put(`/comment/${s}`,o).then(i=>{let a=document.createElement("div");a.innerHTML=i.data,this.editingComment.innerHTML=a.children[0].innerHTML,window.$events.success(this.updatedText),window.components.init(this.editingComment),this.closeUpdateForm(),this.editingComment=null}).catch(window.$events.showValidationErrors).then(()=>{this.hideLoading(t)})}deleteComment(e){let t=e.getAttribute("comment");this.showLoading(e.querySelector("[comment-content]")),window.$http.delete(`/comment/${t}`).then(n=>{e.parentNode.removeChild(e),window.$events.success(this.deletedText),this.updateCount(),this.hideForm()})}saveComment(e){e.preventDefault(),e.stopPropagation();let n={text:this.formInput.value,parent_id:this.parentId||null};this.showLoading(this.form),window.$http.post(`/comment/${this.pageId}`,n).then(o=>{let s=document.createElement("div");s.innerHTML=o.data;let i=s.children[0];this.container.appendChild(i),window.components.init(i),window.$events.success(this.createdText),this.resetForm(),this.updateCount()}).catch(o=>{window.$events.showValidationErrors(o),this.hideLoading(this.form)})}updateCount(){let e=this.container.children.length;this.elem.querySelector("[comments-title]").textContent=window.trans_plural(this.countText,e,{count:e})}resetForm(){this.formInput.value="",this.formContainer.appendChild(this.form),this.hideForm(),this.removeReplyTo(),this.hideLoading(this.form)}showForm(){this.formContainer.style.display="block",this.formContainer.parentNode.style.display="block",this.addButtonContainer.style.display="none",this.formInput.focus(),this.formInput.scrollIntoView({behavior:"smooth"})}hideForm(){this.formContainer.style.display="none",this.formContainer.parentNode.style.display="none",this.getCommentCount()>0?this.elem.appendChild(this.addButtonContainer):this.commentCountBar.appendChild(this.addButtonContainer),this.addButtonContainer.style.display="block"}getCommentCount(){return this.elem.querySelectorAll(".comment-box[comment]").length}setReply(e){this.showForm(),this.parentId=Number(e.getAttribute("local-id")),this.replyToRow.style.display="block";let t=this.replyToRow.querySelector("a");t.textContent=`#${this.parentId}`,t.href=`#comment${this.parentId}`}removeReplyTo(){this.parentId=null,this.replyToRow.style.display="none"}showLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="none";e.querySelector(".form-group.loading").style.display="block"}hideLoading(e){let t=e.querySelectorAll(".form-group");for(let n of t)n.style.display="block";e.querySelector(".form-group.loading").style.display="none"}},Wu=Gu;var Ku=jr(Yu());var Xu=class{constructor(e){if(this.elem=e,this.pageId=e.getAttribute("page-display"),window.importVersioned("code").then(n=>n.highlight()),this.setupPointer(),this.setupNavHighlighting(),this.setupDetailsCodeBlockRefresh(),window.location.hash){let n=window.location.hash.replace(/\%20/g," ").substr(1);this.goToText(n)}let t=document.querySelector(".sidebar-page-nav");t&&We(t,"a","click",(n,o)=>{n.preventDefault(),window.components["tri-layout"][0].showContent();let s=o.getAttribute("href").substr(1);this.goToText(s),window.history.pushState(null,null,"#"+s)})}goToText(e){let t=document.getElementById(e);if(Vr(".page-content [data-highlighted]",n=>{n.removeAttribute("data-highlighted"),n.style.backgroundColor=null}),t!==null)Cr(t);else{let n=Hi(".page-content > div > *",e);n&&Cr(n)}}setupPointer(){let e=document.getElementById("pointer");if(!e)return;e=e.parentNode.removeChild(e);let t=e.querySelector("div.pointer"),n=!1,o=!1,s=!0,i="";We(e,"input","click",(l,u)=>{u.select(),l.stopPropagation()}),Gr(e,["click","focus"],l=>{l.stopPropagation()}),We(e,"span.icon","click",(l,u)=>{l.stopPropagation(),s=!s,u.querySelector('[data-icon="include"]').style.display=s?"none":"inline",u.querySelector('[data-icon="link"]').style.display=s?"inline":"none",a()}),new Ku.default(e.querySelector("button")),Gr(document.body,["click","focus"],l=>{!n||o||(e=e.parentElement.removeChild(e),n=!1)});let a=l=>{let u=s?window.baseUrl(`/link/${this.pageId}#${i}`):`{{@${this.pageId}#${i}}}`;s&&!u.startsWith("http")&&(u=window.location.protocol+"//"+window.location.host+u),e.querySelector("input").value=u;let c=e.querySelector("#pointer-edit");if(c&&l){let f=c.dataset.editHref,d=l.id,h=l.textContent&&l.textContent.substring(0,50);c.href=`${f}?content-id=${d}&content-text=${encodeURIComponent(h)}`}};Vr('.page-content [id^="bkmrk"]',l=>{Gr(l,["mouseup","keyup"],u=>{u.stopPropagation(),window.getSelection().toString().length!==0&&(i=l.id,a(l),l.parentNode.insertBefore(e,l),e.style.display="block",n=!0,o=!0,requestAnimationFrame(()=>{let f=l.getBoundingClientRect(),d=u.pageX-f.left-164;d<0&&(d=0);let h=d/f.width*100;t.style.left=h+"%",setTimeout(()=>{o=!1},100)}))})})}setupNavHighlighting(){if(!("IntersectionObserver"in window)||!("IntersectionObserverEntry"in window)||!("intersectionRatio"in window.IntersectionObserverEntry.prototype))return;let e=document.querySelector(".sidebar-page-nav"),t=document.querySelector(".page-content").querySelectorAll("h1, h2, h3, h4, h5, h6");t.length>0&&e!==null&&n(t);function n(i){let a={rootMargin:"0px 0px 0px 0px",threshold:1},l=new IntersectionObserver(o,a);for(let u of i)l.observe(u)}function o(i,a){for(let l of i){let u=l.intersectionRatio===1;s(l.target.id,u)}}function s(i,a){Vr('a[href="#'+i+'"]',l=>{l.closest("li").classList.toggle("current-heading",a)})}}setupDetailsCodeBlockRefresh(){let e=n=>{[...n.target.querySelectorAll(".CodeMirror")].forEach(s=>s.CodeMirror&&s.CodeMirror.refresh())};[...this.elem.querySelectorAll("details")].forEach(n=>n.addEventListener("toggle",e))}},Zu=Xu;function Qu(r){let e=new Date(r*1e3),t=e.getHours(),n=e.getMinutes();return`${(t>9?"":"0")+t}:${(n>9?"":"0")+n}`}var Ju=class{setup(){this.draftsEnabled=this.$opts.draftsEnabled==="true",this.editorType=this.$opts.editorType,this.pageId=Number(this.$opts.pageId),this.isNewDraft=this.$opts.pageNewDraft==="true",this.hasDefaultTitle=this.$opts.hasDefaultTitle||!1,this.container=this.$el,this.titleElem=this.$refs.titleContainer.querySelector("input"),this.saveDraftButton=this.$refs.saveDraft,this.discardDraftButton=this.$refs.discardDraft,this.discardDraftWrap=this.$refs.discardDraftWrap,this.draftDisplay=this.$refs.draftDisplay,this.draftDisplayIcon=this.$refs.draftDisplayIcon,this.changelogInput=this.$refs.changelogInput,this.changelogDisplay=this.$refs.changelogDisplay,this.draftText=this.$opts.draftText,this.autosaveFailText=this.$opts.autosaveFailText,this.editingPageText=this.$opts.editingPageText,this.draftDiscardedText=this.$opts.draftDiscardedText,this.setChangelogText=this.$opts.setChangelogText,this.editorHTML="",this.editorMarkdown="",this.autoSave={interval:null,frequency:3e4,last:0},this.shownWarningsCache=new Set,this.pageId!==0&&this.draftsEnabled&&window.setTimeout(()=>{this.startAutoSave()},1e3),this.draftDisplay.innerHTML=this.draftText,this.setupListeners(),this.setInitialFocus()}setupListeners(){window.$events.listen("editor-save-draft",this.saveDraft.bind(this)),window.$events.listen("editor-save-page",this.savePage.bind(this)),window.$events.listen("editor-html-change",e=>{this.editorHTML=e}),window.$events.listen("editor-markdown-change",e=>{this.editorMarkdown=e}),this.changelogInput.addEventListener("change",this.updateChangelogDisplay.bind(this)),Ue(this.saveDraftButton,this.saveDraft.bind(this)),Ue(this.discardDraftButton,this.discardDraft.bind(this))}setInitialFocus(){if(this.hasDefaultTitle)return this.titleElem.select();window.setTimeout(()=>{window.$events.emit("editor::focus","")},500)}startAutoSave(){let e=this.titleElem.value.trim()+"::"+this.editorHTML;this.autoSaveInterval=window.setInterval(()=>{if(Date.now()-this.autoSave.last{this.draftDisplayIcon.classList.remove("visible")},2e3)}async discardDraft(){let e;try{e=await window.$http.get(`/ajax/page/${this.pageId}`)}catch(t){return console.error(t)}this.autoSave.interval&&window.clearInterval(this.autoSave.interval),this.draftDisplay.innerText=this.editingPageText,this.toggleDiscardDraftVisibility(!1),window.$events.emit("editor::replace",{html:e.data.html,markdown:e.data.markdown}),this.titleElem.value=e.data.name,window.setTimeout(()=>{this.startAutoSave()},1e3),window.$events.emit("success",this.draftDiscardedText)}updateChangelogDisplay(){let e=this.changelogInput.value.trim();e.length===0?e=this.setChangelogText:e.length>16&&(e=e.slice(0,16)+"..."),this.changelogDisplay.innerText=e}toggleDiscardDraftVisibility(e){this.discardDraftWrap.classList.toggle("hidden",!e)}},ec=Ju;var tc=class{constructor(e){this.elem=e,this.input=e.querySelector("input"),this.resetButton=e.querySelector("[page-picker-reset]"),this.selectButton=e.querySelector("[page-picker-select]"),this.display=e.querySelector("[page-picker-display]"),this.defaultDisplay=e.querySelector("[page-picker-default]"),this.buttonSep=e.querySelector("span.sep"),this.value=this.input.value,this.setupListeners()}setupListeners(){this.selectButton.addEventListener("click",this.showPopup.bind(this)),this.display.parentElement.addEventListener("click",this.showPopup.bind(this)),this.resetButton.addEventListener("click",e=>{this.setValue("","")})}showPopup(){window.EntitySelectorPopup.show(e=>{this.setValue(e.id,e.name)})}setValue(e,t){this.value=e,this.input.value=e,this.controlView(t)}controlView(e){let t=this.value&&this.value!==0;if(Dn(this.resetButton,t),Dn(this.buttonSep,t),Dn(this.defaultDisplay,!t),Dn(this.display,t),t){let n=this.getAssetIdFromVal();this.display.textContent=`#${n}, ${e}`,this.display.href=window.baseUrl(`/link/${n}`)}}getAssetIdFromVal(){return Number(this.value)}};function Dn(r,e){let t=r.tagName==="BUTTON"||r.tagName==="SPAN"?"inline-block":"block";r.style.display=e?t:"none"}var rc=tc;var nc=class{constructor(e){this.container=e,e.querySelector("[permissions-table-toggle-all]").addEventListener("click",this.toggleAllClick.bind(this));let n=e.querySelectorAll("[permissions-table-toggle-all-in-row]");for(let s of n)s.addEventListener("click",this.toggleRowClick.bind(this));let o=e.querySelectorAll("[permissions-table-toggle-all-in-column]");for(let s of o)s.addEventListener("click",this.toggleColumnClick.bind(this))}toggleAllClick(e){e.preventDefault(),this.toggleAllInElement(this.container)}toggleRowClick(e){e.preventDefault(),this.toggleAllInElement(e.target.closest("tr"))}toggleColumnClick(e){e.preventDefault();let t=e.target.closest("th,td"),n=Array.from(t.parentElement.children).indexOf(t),o=t.closest("table").querySelectorAll("tr"),s=[];for(let i of o){let a=i.children[n];a&&s.push(...a.querySelectorAll("input[type=checkbox]"))}this.toggleAllInputs(s)}toggleAllInElement(e){let t=e.querySelectorAll("input[type=checkbox]");this.toggleAllInputs(t)}toggleAllInputs(e){let t=e.length>0?e[0].checked:!1;for(let n of e)n.checked=!t,n.dispatchEvent(new Event("change"))}},ic=nc;var oc=class{setup(){this.container=this.$el,this.hideButtons=this.$manyRefs.hide||[],this.onkeyup=null,this.onHide=null,this.setupListeners()}setupListeners(){let e=null;this.container.addEventListener("mousedown",t=>{e=t.target}),this.container.addEventListener("click",t=>{if(t.target===this.container&&e===this.container)return this.hide()}),Ue(this.hideButtons,t=>this.hide())}hide(e=null){dn(this.container,240,e),this.onkeyup&&(window.removeEventListener("keyup",this.onkeyup),this.onkeyup=null),this.onHide&&this.onHide()}show(e=null,t=null){Oo(this.container,240,e),this.onkeyup=n=>{n.key==="Escape"&&this.hide()},window.addEventListener("keyup",this.onkeyup),this.onHide=t}},sc=oc;var ac=class{constructor(e){this.elem=e,this.colorInput=e.querySelector("input[type=color]"),this.lightColorInput=e.querySelector('input[name="setting-app-color-light"]'),this.resetButton=e.querySelector("[setting-app-color-picker-reset]"),this.defaultButton=e.querySelector("[setting-app-color-picker-default]"),this.colorInput.addEventListener("change",this.updateColor.bind(this)),this.colorInput.addEventListener("input",this.updateColor.bind(this)),this.resetButton.addEventListener("click",t=>{this.colorInput.value=this.colorInput.dataset.current,this.updateColor()}),this.defaultButton.addEventListener("click",t=>{this.colorInput.value=this.colorInput.dataset.default,this.updateColor()})}updateColor(){let e=this.colorInput.value,t=this.hexToRgb(e),n="rgba("+[t.r,t.g,t.b,"0.15"].join(",")+")";this.lightColorInput.value=n;let o=document.getElementById("custom-styles"),s=o.getAttribute("data-color"),i=o.getAttribute("data-color-light");o.innerHTML=o.innerHTML.split(s).join(e),o.innerHTML=o.innerHTML.split(i).join(n),o.setAttribute("data-color",e),o.setAttribute("data-color-light",n)}hexToRgb(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return{r:t?parseInt(t[1],16):0,g:t?parseInt(t[2],16):0,b:t?parseInt(t[3],16):0}}},lc=ac;var uc=class{constructor(e){this.elem=e,this.colorInput=e.querySelector("input[type=color]"),this.resetButton=e.querySelector("[setting-color-picker-reset]"),this.defaultButton=e.querySelector("[setting-color-picker-default]"),this.resetButton.addEventListener("click",t=>{this.colorInput.value=this.colorInput.dataset.current}),this.defaultButton.addEventListener("click",t=>{this.colorInput.value=this.colorInput.dataset.default})}},cc=uc;var dc=class{constructor(e){this.elem=e,this.input=document.getElementById("books-input"),this.shelfBooksList=e.querySelector("[shelf-sort-assigned-books]"),this.initSortable(),this.setupListeners()}initSortable(){let e=this.elem.querySelectorAll(".scroll-box");for(let t of e)new dr(t,{group:"shelf-books",ghostClass:"primary-background-light",animation:150,onSort:this.onChange.bind(this)})}setupListeners(){this.elem.addEventListener("click",e=>{let t=e.target.closest(".scroll-box-item:not(.instruction)");t&&(e.preventDefault(),this.sortItemClick(t))})}sortItemClick(e){let t=this.elem.querySelectorAll(".scroll-box"),n=Array.from(t).filter(o=>e.parentElement!==o);n.length>0&&n[0].appendChild(e),this.onChange()}onChange(){let e=Array.from(this.shelfBooksList.querySelectorAll("[data-id]"));this.input.value=e.map(t=>t.getAttribute("data-id")).join(",")}},fc=dc;var hc=class{constructor(e){this.elem=e,this.toggleElem=e.querySelector(".sidebar-toggle"),this.toggleElem.addEventListener("click",this.toggle.bind(this))}toggle(e=!0){this.elem.classList.toggle("open")}},pc=hc;var mc=class{setup(){this.container=this.$el,this.handleSelector=this.$opts.handleSelector;let e=new dr(this.container,{handle:this.handleSelector,animation:150,onSort:()=>{this.$emit("sort",{ids:e.toArray()})},setData(t,n){let o=n.getAttribute("data-drag-content");if(o){let s=JSON.parse(o);for(let[i,a]of Object.entries(s))t.setData(i,a)}},revertOnSpill:!0,dropBubble:!0,dragoverBubble:!1})}},gc=mc;var vc=class{setup(){this.filter=this.$opts.filter,this.$el.addEventListener("change",e=>{if(this.filter&&!e.target.matches(this.filter))return;let t=this.$el.closest("form");t&&t.submit()})}},yc=vc;var bc=class{setup(){this.tabContentsByName={},this.tabButtonsByName={},this.allContents=[],this.allButtons=[];for(let[e,t]of Object.entries(this.$manyRefs||{})){if(e.startsWith("toggle")){let n=e.replace("toggle","").toLowerCase();Ue(t,o=>this.show(n)),this.allButtons.push(...t),this.tabButtonsByName[n]=t}if(e.startsWith("content")){let n=e.replace("content","").toLowerCase();this.tabContentsByName[n]=t,this.allContents.push(...t)}}}show(e){this.allContents.forEach(o=>{o.classList.add("hidden"),o.classList.remove("selected")}),this.allButtons.forEach(o=>o.classList.remove("selected"));let t=this.tabContentsByName[e]||[],n=this.tabButtonsByName[e]||[];t.length>0&&(t.forEach(o=>{o.classList.remove("hidden"),o.classList.add("selected")}),n.forEach(o=>o.classList.add("selected")))}},xc=bc;var wc=class{setup(){this.addRemoveComponentEl=this.$refs.addRemove,this.container=this.$el,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.container.addEventListener("change",e=>{let t=this.addRemoveComponentEl.components["add-remove-rows"];this.hasEmptyRows()||t.add()})}hasEmptyRows(){return[...this.container.querySelectorAll(this.rowSelector)].find(n=>[...n.querySelectorAll("input")].filter(o=>o.value).length===0)!==void 0}},Ec=wc;var Sc=class{constructor(e){this.elem=e,this.list=e.querySelector("[template-manager-list]"),this.searching=!1,We(this.elem,"[template-action]","click",this.handleTemplateActionClick.bind(this)),We(this.elem,".pagination a","click",this.handlePaginationClick.bind(this)),We(this.elem,".template-item-content","click",this.handleTemplateItemClick.bind(this)),We(this.elem,".template-item","dragstart",this.handleTemplateItemDragStart.bind(this)),this.setupSearchBox()}handleTemplateItemClick(e,t){let n=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(n,"replace")}handleTemplateItemDragStart(e,t){let n=t.closest("[template-id]").getAttribute("template-id");e.dataTransfer.setData("bookstack/template",n),e.dataTransfer.setData("text/plain",n)}handleTemplateActionClick(e,t){e.stopPropagation();let n=t.getAttribute("template-action"),o=t.closest("[template-id]").getAttribute("template-id");this.insertTemplate(o,n)}async insertTemplate(e,t="replace"){let n=await window.$http.get(`/templates/${e}`),o="editor::"+t;window.$events.emit(o,n.data)}async handlePaginationClick(e,t){e.preventDefault();let n=t.getAttribute("href"),o=await window.$http.get(n);this.list.innerHTML=o.data}setupSearchBox(){let e=this.elem.querySelector(".search-box");if(!e)return;let t=e.querySelector("input"),n=e.querySelector("button"),o=e.querySelector("button.search-box-cancel");async function s(){let i=t.value,a=await window.$http.get("/templates",{search:i});o.style.display=i?"block":"none",this.list.innerHTML=a.data}s=s.bind(this),e.addEventListener("keypress",i=>{i.key==="Enter"&&(i.preventDefault(),s())}),n.addEventListener("click",i=>{s()}),o.addEventListener("click",i=>{t.value="",s()})}},Cc=Sc;var Ac=class{constructor(e){this.elem=e,this.input=e.querySelector("input[type=hidden]"),this.checkbox=e.querySelector("input[type=checkbox]"),this.checkbox.addEventListener("change",this.stateChange.bind(this))}stateChange(){this.input.value=this.checkbox.checked?"true":"false";let e=new Event("change");this.input.dispatchEvent(e)}},kc=Ac;var Tc=class{setup(){this.container=this.$refs.container,this.tabs=this.$manyRefs.tab,this.lastLayoutType="none",this.onDestroy=null,this.scrollCache={content:0,info:0},this.lastTabShown="content",this.mobileTabClick=this.mobileTabClick.bind(this),this.updateLayout(),window.addEventListener("resize",e=>{this.updateLayout()},{passive:!0})}updateLayout(){let e="tablet";window.innerWidth<=1e3&&(e="mobile"),window.innerWidth>=1400&&(e="desktop"),e!==this.lastLayoutType&&(this.onDestroy&&(this.onDestroy(),this.onDestroy=null),e==="desktop"?this.setupDesktop():e==="mobile"&&this.setupMobile(),this.lastLayoutType=e)}setupMobile(){for(let e of this.tabs)e.addEventListener("click",this.mobileTabClick);this.onDestroy=()=>{for(let e of this.tabs)e.removeEventListener("click",this.mobileTabClick)}}setupDesktop(){}mobileTabClick(e){let t=e.target.dataset.tab;this.showTab(t)}showContent(){this.showTab("content",!1)}showTab(e,t=!0){this.scrollCache[this.lastTabShown]=document.documentElement.scrollTop;for(let o of this.tabs){let s=o.dataset.tab===e;o.setAttribute("aria-selected",s?"true":"false")}let n=e==="info";if(this.container.classList.toggle("show-info",n),t){let s=document.querySelector("header").getBoundingClientRect().bottom;document.documentElement.scrollTop=this.scrollCache[e]||s,setTimeout(()=>{document.documentElement.scrollTop=this.scrollCache[e]||s},50)}this.lastTabShown=e}},Ic=Tc;var Dc=class{setup(){this.input=this.$refs.input,this.userInfoContainer=this.$refs.userInfo,this.hide=this.$el.components.dropdown.hide,We(this.$el,"a.dropdown-search-item","click",this.selectUser.bind(this))}selectUser(e,t){e.preventDefault();let n=t.getAttribute("data-id");this.input.value=n,this.userInfoContainer.innerHTML=t.innerHTML,this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.hide()}},Lc=Dc;var Fc=class{setup(){this.checkboxes=this.$el.querySelectorAll('input[type="checkbox"]'),this.allCheckbox=this.$el.querySelector('input[type="checkbox"][value="all"]'),this.$el.addEventListener("change",e=>{e.target.checked&&e.target===this.allCheckbox?this.deselectIndividualEvents():e.target.checked&&(this.allCheckbox.checked=!1)})}deselectIndividualEvents(){for(let e of this.checkboxes)e!==this.allCheckbox&&(e.checked=!1)}},Rc=Fc;function Oc(r){for(let e=1;e<5;e++)r.shortcuts.add("meta+"+e,"",["FormatBlock",!1,"h"+(e+1)]);r.shortcuts.add("meta+5","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+d","",["FormatBlock",!1,"p"]),r.shortcuts.add("meta+6","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+q","",["FormatBlock",!1,"blockquote"]),r.shortcuts.add("meta+7","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+e","",["codeeditor",!1,"pre"]),r.shortcuts.add("meta+8","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+shift+E","",["FormatBlock",!1,"code"]),r.shortcuts.add("meta+S","",()=>{window.$events.emit("editor-save-draft")}),r.shortcuts.add("meta+13","",()=>{window.$events.emit("editor-save-page")}),r.shortcuts.add("meta+9","",function(){let e=r.selection.getNode(),t=e?e.closest(".callout"):null,n=["info","success","warning","danger"],s=(n.findIndex(a=>t&&t.classList.contains(a))+1)%n.length,i=n[s];r.formatter.apply("callout"+i)})}function Pc(r){window.$events.listen("editor::replace",({html:e})=>{r.setContent(e)}),window.$events.listen("editor::append",({html:e})=>{let t=r.getContent()+e;r.setContent(t)}),window.$events.listen("editor::prepend",({html:e})=>{let t=e+r.getContent();r.setContent(t)}),window.$events.listen("editor::insert",({html:e})=>{r.insertContent(e)}),window.$events.listen("editor::focus",()=>{r.initialized&&r.focus()})}function Mc(r){let t=new URL(window.location).searchParams.get("content-id");t&&wp(r,t)}function wp(r,e){let t=r.dom.get(encodeURIComponent(e).replace(/!/g,"%21"));!t||(t.scrollIntoView(),r.selection.select(t,!0),r.selection.collapse(!1),r.focus())}var rr,Ln;function Ep(r){return r&&!!(r.textContent||r.innerText)}function Nc(r,e,t){let n=new $r(t.clipboardData||t.dataTransfer);if(!n.hasItems()||n.containsTabularData())return;let o=n.getImages();for(let s of o){let i="image-"+Math.random().toString(16).slice(2),a=window.baseUrl("/loading.gif");t.preventDefault(),setTimeout(()=>{r.insertContent(`

    `),Sp(s,e.pageId).then(l=>{let u=l.name.replace(/"/g,""),c=`${u}`,f=r.dom.create("a",{target:"_blank",href:l.url},c);r.dom.replace(f,i)}).catch(l=>{r.dom.remove(i),window.$events.emit("error",e.translations.imageUploadErrorText),console.log(l)})},10)}}async function Sp(r,e){if(r===null||r.type.indexOf("image")!==0)throw new Error("Not an image file");let t="png";if(r.name){let i=r.name.match(/\.(.+)$/);i.length>1&&(t=i[1])}let n="image-"+Date.now()+"."+t,o=new FormData;return o.append("file",r,n),o.append("uploaded_to",e),(await window.$http.post(window.baseUrl("/images/gallery"),o)).data}function Cp(r,e){let t=r.selection.getNode();t.nodeName==="IMG"&&(rr=r.dom.getParent(t,".mceTemp"),!rr&&t.parentNode.nodeName==="A"&&!Ep(t.parentNode)&&(rr=t.parentNode)),t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="false"&&(Ln=t)}function Ap(r,e,t){let n=r.dom,o=tinymce.dom.RangeUtils.getCaretRangeFromPoint(t.clientX,t.clientY,r.getDoc()),s=t.dataTransfer&&t.dataTransfer.getData("bookstack/template");s&&(t.preventDefault(),window.$http.get(`/templates/${s}`).then(i=>{r.selection.setRng(o),r.undoManager.transact(function(){r.execCommand("mceInsertContent",!1,i.data.html)})})),n.getParent(o.startContainer,".mceTemp")?t.preventDefault():rr&&(t.preventDefault(),r.undoManager.transact(function(){r.selection.setRng(o),r.selection.setNode(rr),n.remove(rr)})),!t.isDefaultPrevented()&&Ln&&(t.preventDefault(),r.undoManager.transact(function(){let i=r.selection.getNode(),a=r.selection.getRng(),l=i.closest("body > *");a.startOffset>a.startContainer.length/2?r.$(l).after(Ln):r.$(l).before(Ln)})),t.isDefaultPrevented()||Nc(r,e,t),rr=null}function _c(r,e){r.on("dragstart",()=>Cp(r,e)),r.on("drop",t=>Ap(r,e,t)),r.on("paste",t=>Nc(r,e,t))}function Bc(r){return r.tagName.toLowerCase()==="code-block"}function Uc(r,e,t,n){window.components.first("code-editor").open(e,t,(o,s)=>{n(o,s),r.focus()})}function $c(r,e){Uc(r,e.getContent(),e.getLanguage(),(t,n)=>{e.setContent(t,n)})}function kp(r){let e=r.getDoc(),t=e.defaultView;class n extends t.HTMLElement{constructor(){super();this.attachShadow({mode:"open"});let s=document.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href",window.baseUrl("/dist/styles.css"));let i=document.createElement("div");i.style.pointerEvents="none",i.contentEditable="false",i.classList.add("CodeMirrorContainer"),this.shadowRoot.append(s,i)}getLanguage(){let s=l=>(l.split(" ").filter(c=>c.startsWith("language-"))[0]||"").replace("language-",""),i=this.querySelector("code"),a=this.querySelector("pre");return s(a.className)||i&&s(i.className)||""}setContent(s,i){this.cm&&importVersioned("code").then(u=>{u.setContent(this.cm,s),u.setMode(this.cm,i,s)});let a=this.querySelector("pre");a||(a=e.createElement("pre"),this.append(a)),a.innerHTML="";let l=e.createElement("code");a.append(l),l.innerText=s,l.className=`language-${i}`}getContent(){let s=this.querySelector("code")||this.querySelector("pre"),i=document.createElement("pre");return i.innerHTML=s.innerHTML.replace().replace(//gi,` -`).replace(/\ufeff/g,""),i.textContent}connectedCallback(){if(this.cm)return;let s=this.shadowRoot.querySelector(".CodeMirrorContainer");importVersioned("code").then(i=>{this.cm=i.wysiwygView(s,this.getContent(),this.getLanguage())})}}t.customElements.define("code-block",n)}function Tp(r,e){r.ui.registry.addIcon("codeblock",''),r.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){r.execCommand("codeeditor")}}),r.addCommand("codeeditor",()=>{let t=r.selection.getNode(),n=t.ownerDocument;if(Bc(t))$c(r,t);else{let o=r.selection.getContent({format:"text"});Uc(r,o,"",(s,i)=>{let a=n.createElement("code-block"),l=n.createElement("pre"),u=n.createElement("code");u.classList.add(`language-${i}`),u.innerText=s,l.append(u),a.append(l),r.insertContent(a.outerHTML)})}}),r.on("dblclick",t=>{let n=r.selection.getNode();Bc(n)&&$c(r,n)}),r.on("PreInit",()=>{r.parser.addNodeFilter("pre",function(t){for(let n of t){let o=new tinymce.html.Node.create("code-block",{contenteditable:"false"}),s=n.getAll("span");for(let i of s)i.unwrap();n.attr("style",null),n.wrap(o)}}),r.parser.addNodeFilter("code-block",function(t){for(let n of t)n.attr("content-editable","false")}),r.serializer.addNodeFilter("code-block",function(t){for(let n of t)n.unwrap()})}),r.on("PreInit",()=>{kp(r)})}function zc(r){return Tp}var kt=null,ir=null,nr={};function Ri(r){return r.hasAttribute("drawio-diagram")}function Ip(r,e=null){kt=r,ir=e,window.ImageManager.show(function(t){if(e){let n=e.querySelector("img");kt.dom.setAttrib(n,"src",t.url),kt.dom.setAttrib(e,"drawio-diagram",t.id)}else{let n=`
    `;kt.insertContent(n)}},"drawio")}function jc(r,e=null){kt=r,ir=e,vt.show(nr.drawioUrl,Lp,Dp)}async function Dp(r){let e="image-"+Math.random().toString(16).slice(2),t=window.baseUrl("/loading.gif"),n=o=>{o.status===413?window.$events.emit("error",nr.translations.serverUploadLimitText):window.$events.emit("error",nr.translations.imageUploadErrorText),console.log(o)};if(ir){vt.close();let o=ir.querySelector("img");try{let s=await vt.upload(r,nr.pageId);kt.dom.setAttrib(o,"src",s.url),kt.dom.setAttrib(ir,"drawio-diagram",s.id)}catch(s){n(s)}return}setTimeout(async()=>{kt.insertContent(`
    `),vt.close();try{let o=await vt.upload(r,nr.pageId);kt.dom.setAttrib(e,"src",o.url),kt.dom.get(e).parentNode.setAttribute("drawio-diagram",o.id)}catch(o){kt.dom.remove(e),n(o)}},5)}function Lp(){if(!ir)return Promise.resolve("");let r=ir.getAttribute("drawio-diagram");return vt.load(r)}function Hc(r){return nr=r,function(e,t){e.addCommand("drawio",()=>{let n=e.selection.getNode();jc(e,Ri(n)?n:null)}),e.ui.registry.addIcon("diagram",``),e.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){e.execCommand("drawio")},fetch(n){n([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(n,o){if(o==="drawing-manager"){let s=e.selection.getNode();Ip(e,Ri(s)?s:null)}}}),e.on("dblclick",n=>{let o=e.selection.getNode();!Ri(o)||jc(e,o)}),e.on("SetContent",function(){let n=e.$("body > div[drawio-diagram]");!n.length||e.undoManager.transact(function(){n.each((o,s)=>{s.setAttribute("contenteditable","false")})})})}}function Fp(r,e){r.addCommand("InsertHorizontalRule",function(){let t=document.createElement("hr"),n=r.selection.getNode();n.parentNode.insertBefore(t,n)}),r.ui.registry.addButton("hr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){r.execCommand("InsertHorizontalRule")}})}function qc(r){return Fp}function Rp(r,e){r.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.ImageManager.show(function(t){let n=t.thumbs.display||t.url,o=``;o+=`${t.name}`,o+="",r.execCommand("mceInsertContent",!1,o)},"gallery")}})}function Vc(r){return Rp}function Op(r,e){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/wysiwyg")};r.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){tinymce.activeEditor.windowManager.openUrl(t)}})}function Gc(r){return Op}function Pp(r,e){r.ui.registry.addIcon("details",''),r.ui.registry.addIcon("togglefold",''),r.ui.registry.addIcon("togglelabel",''),r.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){r.execCommand("InsertDetailsBlock")}}),r.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){Bp(r)}}),r.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Wc(r)}}),r.on("dblclick",t=>{!Fn(r)||t.target.closest("doc-root")||Wc(r)}),r.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){Fn(r).toggleAttribute("open"),r.focus()}}),r.addCommand("InsertDetailsBlock",function(){let t=r.selection.getContent({format:"html"}),n=document.createElement("details"),o=document.createElement("summary"),s="details-"+Date.now();n.setAttribute("data-id",s),n.appendChild(o),t||(t="


    "),n.innerHTML+=t,r.insertContent(n.outerHTML),r.focus();let i=r.dom.$(`[data-id="${s}"]`);if(i){let a=i.find("doc-root > *");a&&a[0].focus(),i.removeAttr("data-id")}}),r.ui.registry.addContextToolbar("details",{predicate:function(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),r.on("PreInit",()=>{$p(r)})}function Wc(r){let e=Fn(r);r.windowManager.open(Np(r)).setData({summary:Mp(e)})}function Fn(r){return r.selection.getNode().closest("details")}function Mp(r){let e=r.querySelector("summary");return e?e.textContent:""}function Np(r){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(e){let{summary:t}=e.getData();_p(r,t),e.close()}}}function _p(r,e){let t=Fn(r);!t||r.undoManager.transact(()=>{let n=t.querySelector("summary");n||(n=document.createElement("summary"),t.prepend(n)),n.textContent=e})}function Bp(r){let e=r.selection.getNode().closest("details"),t=r.selection.getBookmark();if(e){let n=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");r.undoManager.transact(()=>{for(let o of n)e.parentNode.insertBefore(o,e);e.remove()})}r.focus(),r.selection.moveToBookmark(t)}function $p(r){r.parser.addNodeFilter("details",function(e){for(let t of e)Up(t)}),r.serializer.addNodeFilter("details",function(e){for(let t of e)Oi(t),t.attr("open",null)}),r.serializer.addNodeFilter("doc-root",function(e){for(let t of e)t.unwrap()})}function Up(r){Oi(r),r.attr("contenteditable","false");let e=tinymce.html.Node.create("doc-root",{contenteditable:"true"});for(let t of r.children())t.name!=="summary"&&e.append(t);r.append(e)}function Oi(r){r.attr("contenteditable",null);let e=!1;for(let t of r.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&Oi(r)}function Yc(r){return Pp}var zp=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],jp={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}};function Hp(r,e,t){t.filetype==="file"&&window.EntitySelectorPopup.show(n=>{r(n.link,{text:n.name,title:n.name})}),t.filetype==="image"&&window.ImageManager.show(function(n){r(n.url,{alt:n.name})},"gallery")}function qp(r){let e=r.textDirection==="rtl"?"ltr rtl":"",t={formatoverflow:{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"},listoverflow:{icon:"more-drawer",tooltip:"More",items:"outdent indent"},insertoverflow:{icon:"more-drawer",tooltip:"More",items:"hr codeeditor drawio media details"}};return{toolbar:["undo redo","styleselect","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",e,"link table imagemanager-insert insertoverflow","code about fullscreen"].filter(o=>Boolean(o)).join(" | "),groupButtons:t}}function Vp(r){let e=["image","imagetools","table","paste","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details",r.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",zc(r)),window.tinymce.PluginManager.add("customhr",qc(r)),window.tinymce.PluginManager.add("imagemanager",Vc(r)),window.tinymce.PluginManager.add("about",Gc(r)),window.tinymce.PluginManager.add("details",Yc(r)),r.drawioUrl&&(window.tinymce.PluginManager.add("drawio",Hc(r)),e.push("drawio")),e.filter(t=>Boolean(t)).join(" ")}function Gp(){let r=document.head.innerHTML.split(` +`).replace(/\ufeff/g,""),i.textContent}connectedCallback(){let s=Date.now();if(this.cm)return;this.cleanChildContent();let i=this.shadowRoot.querySelector(".CodeMirrorContainer"),a=l=>{this.cm=l.wysiwygView(i,this.getContent(),this.getLanguage()),l.updateLayout(this.cm)};window.importVersioned("code").then(l=>{let u=Date.now()-s<20?20:0;setTimeout(()=>a(l),u)})}cleanChildContent(){let s=this.querySelector("pre");if(!!s)for(let i of s.childNodes)i.nodeName==="#text"&&i.textContent==="\uFEFF"&&i.remove()}}t.customElements.define("code-block",n)}function Tp(r,e){r.ui.registry.addIcon("codeblock",''),r.ui.registry.addButton("codeeditor",{tooltip:"Insert code block",icon:"codeblock",onAction(){r.execCommand("codeeditor")}}),r.addCommand("codeeditor",()=>{let t=r.selection.getNode(),n=t.ownerDocument;if(Bc(t))$c(r,t);else{let o=r.selection.getContent({format:"text"});Uc(r,o,"",(s,i)=>{let a=n.createElement("pre"),l=n.createElement("code");l.classList.add(`language-${i}`),l.innerText=s,a.append(l),r.insertContent(a.outerHTML)})}}),r.on("dblclick",t=>{let n=r.selection.getNode();Bc(n)&&$c(r,n)}),r.on("PreInit",()=>{r.parser.addNodeFilter("pre",function(t){for(let n of t){let o=new tinymce.html.Node.create("code-block",{contenteditable:"false"}),s=n.getAll("span");for(let i of s)i.unwrap();n.attr("style",null),n.wrap(o)}}),r.parser.addNodeFilter("code-block",function(t){for(let n of t)n.attr("contenteditable","false")}),r.serializer.addNodeFilter("code-block",function(t){for(let n of t)n.unwrap()})}),r.on("PreInit",()=>{kp(r)})}function zc(r){return Tp}var kt=null,ir=null,nr={};function Ri(r){return r.hasAttribute("drawio-diagram")}function Ip(r,e=null){kt=r,ir=e,window.ImageManager.show(function(t){if(e){let n=e.querySelector("img");kt.dom.setAttrib(n,"src",t.url),kt.dom.setAttrib(e,"drawio-diagram",t.id)}else{let n=`
    `;kt.insertContent(n)}},"drawio")}function jc(r,e=null){kt=r,ir=e,vt.show(nr.drawioUrl,Lp,Dp)}async function Dp(r){let e="image-"+Math.random().toString(16).slice(2),t=window.baseUrl("/loading.gif"),n=o=>{o.status===413?window.$events.emit("error",nr.translations.serverUploadLimitText):window.$events.emit("error",nr.translations.imageUploadErrorText),console.log(o)};if(ir){vt.close();let o=ir.querySelector("img");try{let s=await vt.upload(r,nr.pageId);kt.dom.setAttrib(o,"src",s.url),kt.dom.setAttrib(ir,"drawio-diagram",s.id)}catch(s){n(s)}return}setTimeout(async()=>{kt.insertContent(`
    `),vt.close();try{let o=await vt.upload(r,nr.pageId);kt.dom.setAttrib(e,"src",o.url),kt.dom.get(e).parentNode.setAttribute("drawio-diagram",o.id)}catch(o){kt.dom.remove(e),n(o)}},5)}function Lp(){if(!ir)return Promise.resolve("");let r=ir.getAttribute("drawio-diagram");return vt.load(r)}function Hc(r){return nr=r,function(e,t){e.addCommand("drawio",()=>{let n=e.selection.getNode();jc(e,Ri(n)?n:null)}),e.ui.registry.addIcon("diagram",``),e.ui.registry.addSplitButton("drawio",{tooltip:"Insert/edit drawing",icon:"diagram",onAction(){e.execCommand("drawio")},fetch(n){n([{type:"choiceitem",text:"Drawing manager",value:"drawing-manager"}])},onItemAction(n,o){if(o==="drawing-manager"){let s=e.selection.getNode();Ip(e,Ri(s)?s:null)}}}),e.on("dblclick",n=>{let o=e.selection.getNode();!Ri(o)||jc(e,o)}),e.on("SetContent",function(){let n=e.$("body > div[drawio-diagram]");!n.length||e.undoManager.transact(function(){n.each((o,s)=>{s.setAttribute("contenteditable","false")})})})}}function Fp(r,e){r.addCommand("InsertHorizontalRule",function(){let t=document.createElement("hr"),n=r.selection.getNode();n.parentNode.insertBefore(t,n)}),r.ui.registry.addButton("hr",{icon:"horizontal-rule",tooltip:"Insert horizontal line",onAction(){r.execCommand("InsertHorizontalRule")}})}function qc(r){return Fp}function Rp(r,e){r.ui.registry.addButton("imagemanager-insert",{title:"Insert image",icon:"image",tooltip:"Insert image",onAction(){window.ImageManager.show(function(t){let n=t.thumbs.display||t.url,o=``;o+=`${t.name}`,o+="",r.execCommand("mceInsertContent",!1,o)},"gallery")}})}function Vc(r){return Rp}function Op(r,e){let t={title:"About the WYSIWYG Editor",url:window.baseUrl("/help/wysiwyg")};r.ui.registry.addButton("about",{icon:"help",tooltip:"About the editor",onAction(){tinymce.activeEditor.windowManager.openUrl(t)}})}function Gc(r){return Op}function Pp(r,e){r.ui.registry.addIcon("details",''),r.ui.registry.addIcon("togglefold",''),r.ui.registry.addIcon("togglelabel",''),r.ui.registry.addButton("details",{icon:"details",tooltip:"Insert collapsible block",onAction(){r.execCommand("InsertDetailsBlock")}}),r.ui.registry.addButton("removedetails",{icon:"table-delete-table",tooltip:"Unwrap",onAction(){Bp(r)}}),r.ui.registry.addButton("editdetials",{icon:"togglelabel",tooltip:"Edit label",onAction(){Wc(r)}}),r.on("dblclick",t=>{!Fn(r)||t.target.closest("doc-root")||Wc(r)}),r.ui.registry.addButton("toggledetails",{icon:"togglefold",tooltip:"Toggle open/closed",onAction(){Fn(r).toggleAttribute("open"),r.focus()}}),r.addCommand("InsertDetailsBlock",function(){let t=r.selection.getContent({format:"html"}),n=document.createElement("details"),o=document.createElement("summary"),s="details-"+Date.now();n.setAttribute("data-id",s),n.appendChild(o),t||(t="


    "),n.innerHTML+=t,r.insertContent(n.outerHTML),r.focus();let i=r.dom.$(`[data-id="${s}"]`);if(i){let a=i.find("doc-root > *");a&&a[0].focus(),i.removeAttr("data-id")}}),r.ui.registry.addContextToolbar("details",{predicate:function(t){return t.nodeName.toLowerCase()==="details"},items:"editdetials toggledetails removedetails",position:"node",scope:"node"}),r.on("PreInit",()=>{$p(r)})}function Wc(r){let e=Fn(r);r.windowManager.open(Np(r)).setData({summary:Mp(e)})}function Fn(r){return r.selection.getNode().closest("details")}function Mp(r){let e=r.querySelector("summary");return e?e.textContent:""}function Np(r){return{title:"Edit collapsible block",body:{type:"panel",items:[{type:"input",name:"summary",label:"Toggle label"}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",text:"Save",primary:!0}],onSubmit(e){let{summary:t}=e.getData();_p(r,t),e.close()}}}function _p(r,e){let t=Fn(r);!t||r.undoManager.transact(()=>{let n=t.querySelector("summary");n||(n=document.createElement("summary"),t.prepend(n)),n.textContent=e})}function Bp(r){let e=r.selection.getNode().closest("details"),t=r.selection.getBookmark();if(e){let n=e.querySelectorAll("details > *:not(summary, doc-root), doc-root > *");r.undoManager.transact(()=>{for(let o of n)e.parentNode.insertBefore(o,e);e.remove()})}r.focus(),r.selection.moveToBookmark(t)}function $p(r){r.parser.addNodeFilter("details",function(e){for(let t of e)Up(t)}),r.serializer.addNodeFilter("details",function(e){for(let t of e)Oi(t),t.attr("open",null)}),r.serializer.addNodeFilter("doc-root",function(e){for(let t of e)t.unwrap()})}function Up(r){Oi(r),r.attr("contenteditable","false");let e=tinymce.html.Node.create("doc-root",{contenteditable:"true"});for(let t of r.children())t.name!=="summary"&&e.append(t);r.append(e)}function Oi(r){r.attr("contenteditable",null);let e=!1;for(let t of r.children())t.name==="doc-root"&&(t.unwrap(),e=!0);e&&Oi(r)}function Yc(r){return Pp}var zp=[{title:"Large Header",format:"h2",preview:"color: blue;"},{title:"Medium Header",format:"h3"},{title:"Small Header",format:"h4"},{title:"Tiny Header",format:"h5"},{title:"Paragraph",format:"p",exact:!0,classes:""},{title:"Blockquote",format:"blockquote"},{title:"Callouts",items:[{title:"Information",format:"calloutinfo"},{title:"Success",format:"calloutsuccess"},{title:"Warning",format:"calloutwarning"},{title:"Danger",format:"calloutdanger"}]}],jp={alignleft:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-left"},aligncenter:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-center"},alignright:{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",classes:"align-right"},calloutsuccess:{block:"p",exact:!0,attributes:{class:"callout success"}},calloutinfo:{block:"p",exact:!0,attributes:{class:"callout info"}},calloutwarning:{block:"p",exact:!0,attributes:{class:"callout warning"}},calloutdanger:{block:"p",exact:!0,attributes:{class:"callout danger"}}};function Hp(r,e,t){t.filetype==="file"&&window.EntitySelectorPopup.show(n=>{r(n.link,{text:n.name,title:n.name})}),t.filetype==="image"&&window.ImageManager.show(function(n){r(n.url,{alt:n.name})},"gallery")}function qp(r){let e=r.textDirection==="rtl"?"ltr rtl":"",t={formatoverflow:{icon:"more-drawer",tooltip:"More",items:"strikethrough superscript subscript inlinecode removeformat"},listoverflow:{icon:"more-drawer",tooltip:"More",items:"outdent indent"},insertoverflow:{icon:"more-drawer",tooltip:"More",items:"hr codeeditor drawio media details"}};return{toolbar:["undo redo","styleselect","bold italic underline forecolor backcolor formatoverflow","alignleft aligncenter alignright alignjustify","bullist numlist listoverflow",e,"link table imagemanager-insert insertoverflow","code about fullscreen"].filter(o=>Boolean(o)).join(" | "),groupButtons:t}}function Vp(r){let e=["image","imagetools","table","paste","link","autolink","fullscreen","code","customhr","autosave","lists","codeeditor","media","imagemanager","about","details",r.textDirection==="rtl"?"directionality":""];return window.tinymce.PluginManager.add("codeeditor",zc(r)),window.tinymce.PluginManager.add("customhr",qc(r)),window.tinymce.PluginManager.add("imagemanager",Vc(r)),window.tinymce.PluginManager.add("about",Gc(r)),window.tinymce.PluginManager.add("details",Yc(r)),r.drawioUrl&&(window.tinymce.PluginManager.add("drawio",Hc(r)),e.push("drawio")),e.filter(t=>Boolean(t)).join(" ")}function Gp(){let r=document.head.innerHTML.split(` `),e=r.findIndex(n=>n.trim()===""),t=r.findIndex(n=>n.trim()==="");return e===-1||t===-1?"":r.slice(e+1,t).join(` `)}function Wp(r){return function(e){e.on("ExecCommand change input NodeChange ObjectResized",t),Pc(e),Oc(e),_c(e,r),e.on("init",()=>{t(),Mc(e),window.editor=e});function t(){let n=e.getContent();r.darkMode&&e.contentDocument.documentElement.classList.add("dark-mode"),window.$events.emit("editor-html-change",n)}window.$events.emitPublic(r.containerElement,"editor-tinymce::setup",{editor:e}),e.ui.registry.addButton("inlinecode",{tooltip:"Inline code",icon:"sourcecode",onAction(){e.execCommand("mceToggleFormat",!1,"code")}})}}function Yp(r){return` html, body, html.dark-mode { diff --git a/version b/version index 4bae82891..23f50df70 100644 --- a/version +++ b/version @@ -1 +1 @@ -v22.02 +v22.02.1