`);return n};vr.prototype.render=function(r,e,t){var n,o,s,i="",a=this.rules;for(n=0,o=r.length;n<o;n++)s=r[n].type,s==="inline"?i+=this.renderInline(r[n].children,e,t):typeof a[s]<"u"?i+=a[r[n].type](r,n,e,t,this):i+=this.renderToken(r,n,e,t);return i};Ka.exports=vr});var Cn=re((Fv,Za)=>{"use strict";function kt(){this.__rules__=[],this.__cache__=null}kt.prototype.__find__=function(r){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===r)return e;return-1};kt.prototype.__compile__=function(){var r=this,e=[""];r.__rules__.forEach(function(t){!t.enabled||t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n)})}),r.__cache__={},e.forEach(function(t){r.__cache__[t]=[],r.__rules__.forEach(function(n){!n.enabled||t&&n.alt.indexOf(t)<0||r.__cache__[t].push(n.fn)})})};kt.prototype.at=function(r,e,t){var n=this.__find__(r),o=t||{};if(n===-1)throw new Error("Parser rule not found: "+r);this.__rules__[n].fn=e,this.__rules__[n].alt=o.alt||[],this.__cache__=null};kt.prototype.before=function(r,e,t,n){var o=this.__find__(r),s=n||{};if(o===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(o,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};kt.prototype.after=function(r,e,t,n){var o=this.__find__(r),s=n||{};if(o===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(o+1,0,{name:e,enabled:!0,fn:t,alt:s.alt||[]}),this.__cache__=null};kt.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null};kt.prototype.enable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var o=this.__find__(n);if(o<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[o].enabled=!0,t.push(n)},this),this.__cache__=null,t};kt.prototype.enableOnly=function(r,e){Array.isArray(r)||(r=[r]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(r,e)};kt.prototype.disable=function(r,e){Array.isArray(r)||(r=[r]);var t=[];return r.forEach(function(n){var o=this.__find__(n);if(o<0){if(e)return;throw new Error("Rules manager: invalid rule name "+n)}this.__rules__[o].enabled=!1,t.push(n)},this),this.__cache__=null,t};kt.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[]};Za.exports=kt});var Ja=re((Rv,Qa)=>{"use strict";var oh=/\r\n?|\n/g,sh=/\0/g;Qa.exports=function(e){var t;t=e.src.replace(oh,`
`),t=t.replace(sh,"\uFFFD"),e.src=t}});var tl=re((Ov,el)=>{"use strict";el.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 nl=re((Pv,rl)=>{"use strict";rl.exports=function(e){var t=e.tokens,n,o,s;for(o=0,s=t.length;o<s;o++)n=t[o],n.type==="inline"&&e.md.inline.parse(n.content,e.md,e.env,n.children)}});var ol=re((Mv,il)=>{"use strict";var ah=_e().arrayReplaceAt;function lh(r){return/^<a[>\s]/i.test(r)}function uh(r){return/^<\/a\s*>/i.test(r)}il.exports=function(e){var t,n,o,s,i,a,l,u,c,f,d,h,p,g,y,b,x=e.tokens,k;if(!!e.md.options.linkify){for(n=0,o=x.length;n<o;n++)if(!(x[n].type!=="inline"||!e.md.linkify.pretest(x[n].content)))for(s=x[n].children,p=0,t=s.length-1;t>=0;t--){if(a=s[t],a.type==="link_close"){for(t--;s[t].level!==a.level&&s[t].type!=="link_open";)t--;continue}if(a.type==="html_inline"&&(lh(a.content)&&p>0&&p--,uh(a.content)&&p++),!(p>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(c=a.content,k=e.md.linkify.match(c),l=[],h=a.level,d=0,k.length>0&&k[0].index===0&&t>0&&s[t-1].type==="text_special"&&(k=k.slice(1)),u=0;u<k.length;u++)g=k[u].url,y=e.md.normalizeLink(g),e.md.validateLink(y)&&(b=k[u].text,k[u].schema?k[u].schema==="mailto:"&&!/^mailto:/i.test(b)?b=e.md.normalizeLinkText("mailto:"+b).replace(/^mailto:/,""):b=e.md.normalizeLinkText(b):b=e.md.normalizeLinkText("http://"+b).replace(/^http:\/\//,""),f=k[u].index,f>d&&(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=b,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=k[u].lastIndex);d<c.length&&(i=new e.Token("text","",0),i.content=c.slice(d),i.level=h,l.push(i)),x[n].children=s=ah(s,t,l)}}}}});var ll=re((_v,al)=>{"use strict";var sl=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,ch=/\((c|tm|r)\)/i,dh=/\((c|tm|r)\)/ig,fh={c:"\xA9",r:"\xAE",tm:"\u2122"};function hh(r,e){return fh[e.toLowerCase()]}function ph(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(dh,hh)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function mh(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&sl.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++}al.exports=function(e){var t;if(!!e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(ch.test(e.tokens[t].content)&&ph(e.tokens[t].children),sl.test(e.tokens[t].content)&&mh(e.tokens[t].children))}});var ml=re((Nv,pl)=>{"use strict";var ul=_e().isWhiteSpace,cl=_e().isPunctChar,dl=_e().isMdAsciiPunct,gh=/['"]/,fl=/['"]/g,hl="\u2019";function An(r,e,t){return r.slice(0,e)+t+r.slice(e+1)}function vh(r,e){var t,n,o,s,i,a,l,u,c,f,d,h,p,g,y,b,x,k,S,O,C;for(S=[],t=0;t<r.length;t++){for(n=r[t],l=r[t].level,x=S.length-1;x>=0&&!(S[x].level<=l);x--);if(S.length=x+1,n.type!=="text")continue;o=n.content,i=0,a=o.length;e:for(;i<a&&(fl.lastIndex=i,s=fl.exec(o),!!s);){if(y=b=!0,i=s.index+1,k=s[0]==="'",c=32,s.index-1>=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<a)f=o.charCodeAt(i);else for(x=t+1;x<r.length&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x++)if(!!r[x].content){f=r[x].content.charCodeAt(0);break}if(d=dl(c)||cl(String.fromCharCode(c)),h=dl(f)||cl(String.fromCharCode(f)),p=ul(c),g=ul(f),g?y=!1:h&&(p||d||(y=!1)),p?b=!1:d&&(g||h||(b=!1)),f===34&&s[0]==='"'&&c>=48&&c<=57&&(b=y=!1),y&&b&&(y=d,b=h),!y&&!b){k&&(n.content=An(n.content,s.index,hl));continue}if(b){for(x=S.length-1;x>=0&&(u=S[x],!(S[x].level<l));x--)if(u.single===k&&S[x].level===l){u=S[x],k?(O=e.md.options.quotes[2],C=e.md.options.quotes[3]):(O=e.md.options.quotes[0],C=e.md.options.quotes[1]),n.content=An(n.content,s.index,C),r[u.token].content=An(r[u.token].content,u.pos,O),i+=C.length-1,u.token===t&&(i+=O.length-1),o=n.content,a=o.length,S.length=x;continue e}}y?S.push({token:t,pos:s.index,single:k,level:l}):b&&k&&(n.content=An(n.content,s.index,hl))}}}pl.exports=function(e){var t;if(!!e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!gh.test(e.tokens[t].content)||vh(e.tokens[t].children,e)}});var vl=re((Bv,gl)=>{"use strict";gl.exports=function(e){var t,n,o,s,i,a,l=e.tokens;for(t=0,n=l.length;t<n;t++)if(l[t].type==="inline"){for(o=l[t].children,i=o.length,s=0;s<i;s++)o[s].type==="text_special"&&(o[s].type="text");for(s=a=0;s<i;s++)o[s].type==="text"&&s+1<i&&o[s+1].type==="text"?o[s+1].content=o[s].content+o[s+1].content:(s!==a&&(o[a]=o[s]),a++);s!==a&&(o.length=a)}}});var kn=re(($v,yl)=>{"use strict";function yr(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}yr.prototype.attrIndex=function(e){var t,n,o;if(!this.attrs)return-1;for(t=this.attrs,n=0,o=t.length;n<o;n++)if(t[n][0]===e)return n;return-1};yr.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};yr.prototype.attrSet=function(e,t){var n=this.attrIndex(e),o=[e,t];n<0?this.attrPush(o):this.attrs[n]=o};yr.prototype.attrGet=function(e){var t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n};yr.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};yl.exports=yr});var wl=re((Uv,xl)=>{"use strict";var yh=kn();function bl(r,e,t){this.src=r,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}bl.prototype.Token=yh;xl.exports=bl});var Sl=re((zv,El)=>{"use strict";var bh=Cn(),zi=[["normalize",Ja()],["block",tl()],["inline",nl()],["linkify",ol()],["replacements",ll()],["smartquotes",ml()],["text_join",vl()]];function ji(){this.ruler=new bh;for(var r=0;r<zi.length;r++)this.ruler.push(zi[r][0],zi[r][1])}ji.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r)};ji.prototype.State=wl();El.exports=ji});var kl=re((jv,Al)=>{"use strict";var Hi=_e().isSpace;function qi(r,e){var t=r.bMarks[e]+r.tShift[e],n=r.eMarks[e];return r.src.slice(t,n)}function Cl(r){var e=[],t=0,n=r.length,o,s=!1,i=0,a="";for(o=r.charCodeAt(t);t<n;)o===124&&(s?(a+=r.substring(i,t-1),i=t):(e.push(a+r.substring(i,t)),a="",i=t+1)),s=o===92,t++,o=r.charCodeAt(t);return e.push(a+r.substring(i)),e}Al.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,p,g,y,b,x,k,S,O,C;if(t+2>n||(c=t+1,e.sCount[c]<e.blkIndent)||e.sCount[c]-e.blkIndent>=4||(a=e.bMarks[c]+e.tShift[c],a>=e.eMarks[c])||(O=e.src.charCodeAt(a++),O!==124&&O!==45&&O!==58)||a>=e.eMarks[c]||(C=e.src.charCodeAt(a++),C!==124&&C!==45&&C!==58&&!Hi(C))||O===45&&Hi(C))return!1;for(;a<e.eMarks[c];){if(s=e.src.charCodeAt(a),s!==124&&s!==45&&s!==58&&!Hi(s))return!1;a++}for(i=qi(e,t+1),f=i.split("|"),p=[],l=0;l<f.length;l++){if(g=f[l].trim(),!g){if(l===0||l===f.length-1)continue;return!1}if(!/^:?-+:?$/.test(g))return!1;g.charCodeAt(g.length-1)===58?p.push(g.charCodeAt(0)===58?"center":"right"):g.charCodeAt(0)===58?p.push("left"):p.push("")}if(i=qi(e,t).trim(),i.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(f=Cl(i),f.length&&f[0]===""&&f.shift(),f.length&&f[f.length-1]===""&&f.pop(),d=f.length,d===0||d!==p.length))return!1;if(o)return!0;for(x=e.parentType,e.parentType="table",S=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<f.length;l++)h=e.push("th_open","th",1),p[l]&&(h.attrs=[["style","text-align:"+p[l]]]),h=e.push("inline","",0),h.content=f[l].trim(),h.children=[],h=e.push("th_close","th",-1);for(h=e.push("tr_close","tr",-1),h=e.push("thead_close","thead",-1),c=t+2;c<n&&!(e.sCount[c]<e.blkIndent);c++){for(k=!1,l=0,u=S.length;l<u;l++)if(S[l](e,c,n,!0)){k=!0;break}if(k||(i=qi(e,c).trim(),!i)||e.sCount[c]-e.blkIndent>=4)break;for(f=Cl(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=b=[t+2,0]),h=e.push("tr_open","tr",1),h.map=[c,c+1],l=0;l<d;l++)h=e.push("td_open","td",1),p[l]&&(h.attrs=[["style","text-align:"+p[l]]]),h=e.push("inline","",0),h.content=f[l]?f[l].trim():"",h.children=[],h=e.push("td_close","td",-1);h=e.push("tr_close","tr",-1)}return b&&(h=e.push("tbody_close","tbody",-1),b[1]=c),h=e.push("table_close","table",-1),y[1]=c,e.parentType=x,e.line=c,!0}});var Il=re((Hv,Tl)=>{"use strict";Tl.exports=function(e,t,n){var o,s,i;if(e.sCount[t]-e.blkIndent<4)return!1;for(s=o=t+1;o<n;){if(e.isEmpty(o)){o++;continue}if(e.sCount[o]-e.blkIndent>=4){o++,s=o;continue}break}return e.line=s,i=e.push("code_block","code",0),i.content=e.getLines(t,s,4+e.blkIndent,!1)+`
`,i.map=[t,e.line],!0}});var Ll=re((qv,Dl)=>{"use strict";Dl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d=!1,h=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||h+3>p||(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,p),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],p=e.eMarks[l],h<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(h)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(h=e.skipChars(h,s),!(h-u<i)&&(h=e.skipSpaces(h),!(h<p)))){d=!0;break}return i=e.sCount[t],e.line=l+(d?1:0),c=e.push("fence","code",0),c.info=a,c.content=e.getLines(t+1,l,i,!0),c.markup=f,c.map=[t,e.line],!0}});var Ol=re((Vv,Rl)=>{"use strict";var Fl=_e().isSpace;Rl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,p,g,y,b,x,k,S,O,C,P,A,D=e.lineMax,I=e.bMarks[t]+e.tShift[t],M=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(I++)!==62)return!1;if(o)return!0;for(l=h=e.sCount[t]+1,e.src.charCodeAt(I)===32?(I++,l++,h++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[t]+h)%4===3?(I++,l++,h++,s=!1):s=!0):S=!1,p=[e.bMarks[t]],e.bMarks[t]=I;I<M&&(i=e.src.charCodeAt(I),Fl(i));){i===9?h+=4-(h+e.bsCount[t]+(s?1:0))%4:h++;I++}for(g=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(S?1:0),c=I>=M,x=[e.sCount[t]],e.sCount[t]=h-l,k=[e.tShift[t]],e.tShift[t]=I-e.bMarks[t],C=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",d=t+1;d<n&&(A=e.sCount[d]<e.blkIndent,I=e.bMarks[d]+e.tShift[d],M=e.eMarks[d],!(I>=M));d++){if(e.src.charCodeAt(I++)===62&&!A){for(l=h=e.sCount[d]+1,e.src.charCodeAt(I)===32?(I++,l++,h++,s=!1,S=!0):e.src.charCodeAt(I)===9?(S=!0,(e.bsCount[d]+h)%4===3?(I++,l++,h++,s=!1):s=!0):S=!1,p.push(e.bMarks[d]),e.bMarks[d]=I;I<M&&(i=e.src.charCodeAt(I),Fl(i));){i===9?h+=4-(h+e.bsCount[d]+(s?1:0))%4:h++;I++}c=I>=M,g.push(e.bsCount[d]),e.bsCount[d]=e.sCount[d]+1+(S?1:0),x.push(e.sCount[d]),e.sCount[d]=h-l,k.push(e.tShift[d]),e.tShift[d]=I-e.bMarks[d];continue}if(c)break;for(O=!1,a=0,u=C.length;a<u;a++)if(C[a](e,d,n,!0)){O=!0;break}if(O){e.lineMax=d,e.blkIndent!==0&&(p.push(e.bMarks[d]),g.push(e.bsCount[d]),k.push(e.tShift[d]),x.push(e.sCount[d]),e.sCount[d]-=e.blkIndent);break}p.push(e.bMarks[d]),g.push(e.bsCount[d]),k.push(e.tShift[d]),x.push(e.sCount[d]),e.sCount[d]=-1}for(y=e.blkIndent,e.blkIndent=0,P=e.push("blockquote_open","blockquote",1),P.markup=">",P.map=f=[t,0],e.md.block.tokenize(e,t,d),P=e.push("blockquote_close","blockquote",-1),P.markup=">",e.lineMax=D,e.parentType=b,f[1]=e.line,a=0;a<k.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=k[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=g[a];return e.blkIndent=y,!0}});var Ml=re((Gv,Pl)=>{"use strict";var xh=_e().isSpace;Pl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u++),s!==42&&s!==45&&s!==95))return!1;for(i=1;u<c;){if(a=e.src.charCodeAt(u++),a!==s&&!xh(a))return!1;a===s&&i++}return i<3?!1:(o||(e.line=t+1,l=e.push("hr","hr",0),l.map=[t,e.line],l.markup=Array(i+1).join(String.fromCharCode(s))),!0)}});var Ul=re((Wv,$l)=>{"use strict";var Bl=_e().isSpace;function _l(r,e){var t,n,o,s;return n=r.bMarks[e]+r.tShift[e],o=r.eMarks[e],t=r.src.charCodeAt(n++),t!==42&&t!==45&&t!==43||n<o&&(s=r.src.charCodeAt(n),!Bl(s))?-1:n}function Nl(r,e){var t,n=r.bMarks[e]+r.tShift[e],o=n,s=r.eMarks[e];if(o+1>=s||(t=r.src.charCodeAt(o++),t<48||t>57))return-1;for(;;){if(o>=s)return-1;if(t=r.src.charCodeAt(o++),t>=48&&t<=57){if(o-n>=10)return-1;continue}if(t===41||t===46)break;return-1}return o<s&&(t=r.src.charCodeAt(o),!Bl(t))?-1:o}function wh(r,e){var t,n,o=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===o&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].hidden=!0,r.tokens[t].hidden=!0,t+=2)}$l.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,p,g,y,b,x,k,S,O,C,P,A,D,I,M,N,B,H,Z,W,te=!1,ne=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(o&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(te=!0),(M=Nl(e,t))>=0){if(f=!0,B=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(B,M-1)),te&&b!==1)return!1}else if((M=_l(e,t))>=0)f=!1;else return!1;if(te&&e.skipSpaces(M)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(M-1),o)return!0;for(g=e.tokens.length,f?(W=e.push("ordered_list_open","ol",1),b!==1&&(W.attrs=[["start",b]])):W=e.push("bullet_list_open","ul",1),W.map=p=[t,0],W.markup=String.fromCharCode(y),k=t,N=!1,Z=e.md.block.ruler.getRules("list"),C=e.parentType,e.parentType="list";k<n;){for(I=M,x=e.eMarks[k],c=S=e.sCount[k]+M-(e.bMarks[t]+e.tShift[t]);I<x;){if(s=e.src.charCodeAt(I),s===9)S+=4-(S+e.bsCount[k])%4;else if(s===32)S++;else break;I++}if(i=I,i>=x?u=1:u=S-c,u>4&&(u=1),l=c+u,W=e.push("list_item_open","li",1),W.markup=String.fromCharCode(y),W.map=d=[t,0],f&&(W.info=e.src.slice(B,M-1)),D=e.tight,A=e.tShift[t],P=e.sCount[t],O=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=i-e.bMarks[t],e.sCount[t]=S,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||N)&&(ne=!1),N=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=O,e.tShift[t]=A,e.sCount[t]=P,e.tight=D,W=e.push("list_item_close","li",-1),W.markup=String.fromCharCode(y),k=t=e.line,d[1]=k,i=e.bMarks[t],k>=n||e.sCount[k]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(H=!1,a=0,h=Z.length;a<h;a++)if(Z[a](e,k,n,!0)){H=!0;break}if(H)break;if(f){if(M=Nl(e,k),M<0)break;B=e.bMarks[k]+e.tShift[k]}else if(M=_l(e,k),M<0)break;if(y!==e.src.charCodeAt(M-1))break}return f?W=e.push("ordered_list_close","ol",-1):W=e.push("bullet_list_close","ul",-1),W.markup=String.fromCharCode(y),p[1]=k,e.line=k,e.parentType=C,ne&&wh(e,g),!0}});var jl=re((Yv,zl)=>{"use strict";var Eh=_e().normalizeReference,Tn=_e().isSpace;zl.exports=function(e,t,n,o){var s,i,a,l,u,c,f,d,h,p,g,y,b,x,k,S,O=0,C=e.bMarks[t]+e.tShift[t],P=e.eMarks[t],A=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(C)!==91)return!1;for(;++C<P;)if(e.src.charCodeAt(C)===93&&e.src.charCodeAt(C-1)!==92){if(C+1===P||e.src.charCodeAt(C+1)!==58)return!1;break}for(l=e.lineMax,k=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";A<l&&!e.isEmpty(A);A++)if(!(e.sCount[A]-e.blkIndent>3)&&!(e.sCount[A]<0)){for(x=!1,c=0,f=k.length;c<f;c++)if(k[c](e,A,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,A,e.blkIndent,!1).trim(),P=b.length,C=1;C<P;C++){if(s=b.charCodeAt(C),s===91)return!1;if(s===93){h=C;break}else s===10?O++:s===92&&(C++,C<P&&b.charCodeAt(C)===10&&O++)}if(h<0||b.charCodeAt(h+1)!==58)return!1;for(C=h+2;C<P;C++)if(s=b.charCodeAt(C),s===10)O++;else if(!Tn(s))break;if(g=e.md.helpers.parseLinkDestination(b,C,P),!g.ok||(u=e.md.normalizeLink(g.str),!e.md.validateLink(u)))return!1;for(C=g.pos,O+=g.lines,i=C,a=O,y=C;C<P;C++)if(s=b.charCodeAt(C),s===10)O++;else if(!Tn(s))break;for(g=e.md.helpers.parseLinkTitle(b,C,P),C<P&&y!==C&&g.ok?(S=g.str,C=g.pos,O+=g.lines):(S="",C=i,O=a);C<P&&(s=b.charCodeAt(C),!!Tn(s));)C++;if(C<P&&b.charCodeAt(C)!==10&&S)for(S="",C=i,O=a;C<P&&(s=b.charCodeAt(C),!!Tn(s));)C++;return C<P&&b.charCodeAt(C)!==10||(d=Eh(b.slice(1,h)),!d)?!1:(o||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[d]>"u"&&(e.env.references[d]={title:S,href:u}),e.parentType=p,e.line=t+O+1),!0)}});var ql=re((Kv,Hl)=>{"use strict";Hl.exports=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]});var Gi=re((Xv,Vi)=>{"use strict";var Sh="[a-zA-Z_:][a-zA-Z0-9:._-]*",Ch="[^\"'=<>`\\x00-\\x20]+",Ah="'[^']*'",kh='"[^"]*"',Th="(?:"+Ch+"|"+Ah+"|"+kh+")",Ih="(?:\\s+"+Sh+"(?:\\s*=\\s*"+Th+")?)",Vl="<[A-Za-z][A-Za-z0-9\\-]*"+Ih+"*\\s*\\/?>",Gl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",Dh="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",Lh="<[?][\\s\\S]*?[?]>",Fh="<![A-Z]+\\s+[^>]*>",Rh="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",Oh=new RegExp("^(?:"+Vl+"|"+Gl+"|"+Dh+"|"+Lh+"|"+Fh+"|"+Rh+")"),Ph=new RegExp("^(?:"+Vl+"|"+Gl+")");Vi.exports.HTML_TAG_RE=Oh;Vi.exports.HTML_OPEN_CLOSE_TAG_RE=Ph});var Yl=re((Zv,Wl)=>{"use strict";var Mh=ql(),_h=Gi().HTML_OPEN_CLOSE_TAG_RE,br=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+Mh.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(_h.source+"\\s*$"),/^$/,!1]];Wl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(u)!==60)return!1;for(l=e.src.slice(u,c),s=0;s<br.length&&!br[s][0].test(l);s++);if(s===br.length)return!1;if(o)return br[s][2];if(i=t+1,!br[s][1].test(l)){for(;i<n&&!(e.sCount[i]<e.blkIndent);i++)if(u=e.bMarks[i]+e.tShift[i],c=e.eMarks[i],l=e.src.slice(u,c),br[s][1].test(l)){l.length!==0&&i++;break}}return e.line=i,a=e.push("html_block","",0),a.map=[t,i],a.content=e.getLines(t,i,e.blkIndent,!0),!0}});var Zl=re((Qv,Xl)=>{"use strict";var Kl=_e().isSpace;Xl.exports=function(e,t,n,o){var s,i,a,l,u=e.bMarks[t]+e.tShift[t],c=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(u),s!==35||u>=c))return!1;for(i=1,s=e.src.charCodeAt(++u);s===35&&u<c&&i<=6;)i++,s=e.src.charCodeAt(++u);return i>6||u<c&&!Kl(s)?!1:(o||(c=e.skipSpacesBack(c,u),a=e.skipCharsBack(c,35,u),a>u&&Kl(e.src.charCodeAt(a-1))&&(c=a),e.line=t+1,l=e.push("heading_open","h"+String(i),1),l.markup="########".slice(0,i),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(u,c).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(i),-1),l.markup="########".slice(0,i)),!0)}});var Jl=re((Jv,Ql)=>{"use strict";Ql.exports=function(e,t,n){var o,s,i,a,l,u,c,f,d,h=t+1,p,g=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";h<n&&!e.isEmpty(h);h++)if(!(e.sCount[h]-e.blkIndent>3)){if(e.sCount[h]>=e.blkIndent&&(u=e.bMarks[h]+e.tShift[h],c=e.eMarks[h],u<c&&(d=e.src.charCodeAt(u),(d===45||d===61)&&(u=e.skipChars(u,d),u=e.skipSpaces(u),u>=c)))){f=d===61?1:2;break}if(!(e.sCount[h]<0)){for(s=!1,i=0,a=g.length;i<a;i++)if(g[i](e,h,n,!0)){s=!0;break}if(s)break}}return f?(o=e.getLines(t,h,e.blkIndent,!1).trim(),e.line=h+1,l=e.push("heading_open","h"+String(f),1),l.markup=String.fromCharCode(d),l.map=[t,e.line],l=e.push("inline","",0),l.content=o,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(f),-1),l.markup=String.fromCharCode(d),e.parentType=p,!0):!1}});var tu=re((ey,eu)=>{"use strict";eu.exports=function(e,t){var n,o,s,i,a,l,u=t+1,c=e.md.block.ruler.getRules("paragraph"),f=e.lineMax;for(l=e.parentType,e.parentType="paragraph";u<f&&!e.isEmpty(u);u++)if(!(e.sCount[u]-e.blkIndent>3)&&!(e.sCount[u]<0)){for(o=!1,s=0,i=c.length;s<i;s++)if(c[s](e,u,f,!0)){o=!0;break}if(o)break}return n=e.getLines(t,u,e.blkIndent,!1).trim(),e.line=u,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=n,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var iu=re((ty,nu)=>{"use strict";var ru=kn(),In=_e().isSpace;function Pt(r,e,t,n){var o,s,i,a,l,u,c,f;for(this.src=r,this.md=e,this.env=t,this.tokens=n,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",s=this.src,f=!1,i=a=u=c=0,l=s.length;a<l;a++){if(o=s.charCodeAt(a),!f)if(In(o)){u++,o===9?c+=4-c%4:c++;continue}else f=!0;(o===10||a===l-1)&&(o!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(u),this.sCount.push(c),this.bsCount.push(0),f=!1,u=0,c=0,i=a+1)}this.bMarks.push(s.length),this.eMarks.push(s.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}Pt.prototype.push=function(r,e,t){var n=new ru(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};Pt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Pt.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Pt.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!In(t));e++);return e};Pt.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!In(this.src.charCodeAt(--e)))return e+1;return e};Pt.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};Pt.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e};Pt.prototype.getLines=function(e,t,n,o){var s,i,a,l,u,c,f,d=e;if(e>=t)return"";for(c=new Array(t-e),s=0;d<t;d++,s++){for(i=0,f=l=this.bMarks[d],d+1<t||o?u=this.eMarks[d]+1:u=this.eMarks[d];l<u&&i<n;){if(a=this.src.charCodeAt(l),In(a))a===9?i+=4-(i+this.bsCount[d])%4:i++;else if(l-f<this.tShift[d])i++;else break;l++}i>n?c[s]=new Array(i-n+1).join(" ")+this.src.slice(l,u):c[s]=this.src.slice(l,u)}return c.join("")};Pt.prototype.Token=ru;nu.exports=Pt});var su=re((ry,ou)=>{"use strict";var Nh=Cn(),Dn=[["table",kl(),["paragraph","reference"]],["code",Il()],["fence",Ll(),["paragraph","reference","blockquote","list"]],["blockquote",Ol(),["paragraph","reference","blockquote","list"]],["hr",Ml(),["paragraph","reference","blockquote","list"]],["list",Ul(),["paragraph","reference","blockquote"]],["reference",jl()],["html_block",Yl(),["paragraph","reference","blockquote"]],["heading",Zl(),["paragraph","reference","blockquote"]],["lheading",Jl()],["paragraph",tu()]];function Ln(){this.ruler=new Nh;for(var r=0;r<Dn.length;r++)this.ruler.push(Dn[r][0],Dn[r][1],{alt:(Dn[r][2]||[]).slice()})}Ln.prototype.tokenize=function(r,e,t){for(var n,o,s=this.ruler.getRules(""),i=s.length,a=e,l=!1,u=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=u){r.line=t;break}for(o=0;o<i&&(n=s[o](r,a,t,!1),!n);o++);r.tight=!l,r.isEmpty(r.line-1)&&(l=!0),a=r.line,a<t&&r.isEmpty(a)&&(l=!0,a++,r.line=a)}};Ln.prototype.parse=function(r,e,t,n){var o;!r||(o=new this.State(r,e,t,n),this.tokenize(o,o.line,o.lineMax))};Ln.prototype.State=iu();ou.exports=Ln});var lu=re((ny,au)=>{"use strict";function Bh(r){switch(r){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}au.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!Bh(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var cu=re((iy,uu)=>{"use strict";var $h=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;uu.exports=function(e,t){var n,o,s,i,a,l,u,c;return!e.md.options.linkify||e.linkLevel>0||(n=e.pos,o=e.posMax,n+3>o)||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47||(s=e.pending.match($h),!s)||(i=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-i.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),u=e.md.normalizeLink(l),!e.md.validateLink(u))?!1:(t||(e.pending=e.pending.slice(0,-i.length),c=e.push("link_open","a",1),c.attrs=[["href",u]],c.markup="linkify",c.info="auto",c=e.push("text","",0),c.content=e.md.normalizeLinkText(l),c=e.push("link_close","a",-1),c.markup="linkify",c.info="auto"),e.pos+=l.length-i.length,!0)}});var fu=re((oy,du)=>{"use strict";var Uh=_e().isSpace;du.exports=function(e,t){var n,o,s,i=e.pos;if(e.src.charCodeAt(i)!==10)return!1;if(n=e.pending.length-1,o=e.posMax,!t)if(n>=0&&e.pending.charCodeAt(n)===32)if(n>=1&&e.pending.charCodeAt(n-1)===32){for(s=n-1;s>=1&&e.pending.charCodeAt(s-1)===32;)s--;e.pending=e.pending.slice(0,s),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(i++;i<o&&Uh(e.src.charCodeAt(i));)i++;return e.pos=i,!0}});var pu=re((sy,hu)=>{"use strict";var zh=_e().isSpace,Yi=[];for(Wi=0;Wi<256;Wi++)Yi.push(0);var Wi;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){Yi[r.charCodeAt(0)]=1});hu.exports=function(e,t){var n,o,s,i,a,l=e.pos,u=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=u))return!1;if(n=e.src.charCodeAt(l),n===10){for(t||e.push("hardbreak","br",0),l++;l<u&&(n=e.src.charCodeAt(l),!!zh(n));)l++;return e.pos=l,!0}return i=e.src[l],n>=55296&&n<=56319&&l+1<u&&(o=e.src.charCodeAt(l+1),o>=56320&&o<=57343&&(i+=e.src[l+1],l++)),s="\\"+i,t||(a=e.push("text_special","",0),n<256&&Yi[n]!==0?a.content=i:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var gu=re((ay,mu)=>{"use strict";mu.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<o&&e.src.charCodeAt(f)===96;)f++;if(s=e.src.slice(n,f),u=s.length,e.backticksScanned&&(e.backticks[u]||0)<=n)return t||(e.pending+=s),e.pos+=u,!0;for(a=l=f;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<o&&e.src.charCodeAt(l)===96;)l++;if(c=l-a,c===u)return t||(i=e.push("code_inline","code",0),i.markup=s,i.content=e.src.slice(f,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[c]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=u,!0}});var Xi=re((ly,Ki)=>{"use strict";Ki.exports.tokenize=function(e,t){var n,o,s,i,a,l=e.pos,u=e.src.charCodeAt(l);if(t||u!==126||(o=e.scanDelims(e.pos,!0),i=o.length,a=String.fromCharCode(u),i<2))return!1;for(i%2&&(s=e.push("text","",0),s.content=a,i--),n=0;n<i;n+=2)s=e.push("text","",0),s.content=a+a,e.delimiters.push({marker:u,length:0,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function vu(r,e){var t,n,o,s,i,a=[],l=e.length;for(t=0;t<l;t++)o=e[t],o.marker===126&&o.end!==-1&&(s=e[o.end],i=r.tokens[o.token],i.type="s_open",i.tag="s",i.nesting=1,i.markup="~~",i.content="",i=r.tokens[s.token],i.type="s_close",i.tag="s",i.nesting=-1,i.markup="~~",i.content="",r.tokens[s.token-1].type==="text"&&r.tokens[s.token-1].content==="~"&&a.push(s.token-1));for(;a.length;){for(t=a.pop(),n=t+1;n<r.tokens.length&&r.tokens[n].type==="s_close";)n++;n--,t!==n&&(i=r.tokens[n],r.tokens[n]=r.tokens[t],r.tokens[t]=i)}}Ki.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(vu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&vu(e,n[t].delimiters)}});var Qi=re((uy,Zi)=>{"use strict";Zi.exports.tokenize=function(e,t){var n,o,s,i=e.pos,a=e.src.charCodeAt(i);if(t||a!==95&&a!==42)return!1;for(o=e.scanDelims(e.pos,a===42),n=0;n<o.length;n++)s=e.push("text","",0),s.content=String.fromCharCode(a),e.delimiters.push({marker:a,length:o.length,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function yu(r,e){var t,n,o,s,i,a,l=e.length;for(t=l-1;t>=0;t--)n=e[t],!(n.marker!==95&&n.marker!==42)&&n.end!==-1&&(o=e[n.end],a=t>0&&e[t-1].end===n.end+1&&e[t-1].marker===n.marker&&e[t-1].token===n.token-1&&e[n.end+1].token===o.token+1,i=String.fromCharCode(n.marker),s=r.tokens[n.token],s.type=a?"strong_open":"em_open",s.tag=a?"strong":"em",s.nesting=1,s.markup=a?i+i:i,s.content="",s=r.tokens[o.token],s.type=a?"strong_close":"em_close",s.tag=a?"strong":"em",s.nesting=-1,s.markup=a?i+i:i,s.content="",a&&(r.tokens[e[t-1].token].content="",r.tokens[e[n.end+1].token].content="",t--))}Zi.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(yu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&yu(e,n[t].delimiters)}});var xu=re((cy,bu)=>{"use strict";var jh=_e().normalizeReference,Ji=_e().isSpace;bu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,d="",h="",p=e.pos,g=e.posMax,y=e.pos,b=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,i=e.md.helpers.parseLinkLabel(e,e.pos,!0),i<0))return!1;if(l=i+1,l<g&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<g&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(l>=g)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<g&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);if(u=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<g&&y!==l&&u.ok)for(h=u.str,l=u.pos;l<g&&(o=e.src.charCodeAt(l),!(!Ji(o)&&o!==10));l++);}(l>=g||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<g&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(y,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),c=e.env.references[jh(s)],!c)return e.pos=p,!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.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,f=e.push("link_close","a",-1)),e.pos=l,e.posMax=g,!0}});var Eu=re((dy,wu)=>{"use strict";var Hh=_e().normalizeReference,eo=_e().isSpace;wu.exports=function(e,t){var n,o,s,i,a,l,u,c,f,d,h,p,g,y="",b=e.pos,x=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(u=a+1,u<x&&e.src.charCodeAt(u)===40){for(u++;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(u>=x)return!1;for(g=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=""),g=u;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);if(f=e.md.helpers.parseLinkTitle(e.src,u,e.posMax),u<x&&g!==u&&f.ok)for(d=f.str,u=f.pos;u<x&&(o=e.src.charCodeAt(u),!(!eo(o)&&o!==10));u++);else d="";if(u>=x||e.src.charCodeAt(u)!==41)return e.pos=b,!1;u++}else{if(typeof e.env.references>"u")return!1;if(u<x&&e.src.charCodeAt(u)===91?(g=u+1,u=e.md.helpers.parseLinkLabel(e,u),u>=0?i=e.src.slice(g,u++):u=a+1):u=a+1,i||(i=e.src.slice(l,a)),c=e.env.references[Hh(i)],!c)return e.pos=b,!1;y=c.href,d=c.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),h=e.push("image","img",0),h.attrs=n=[["src",y],["alt",""]],h.children=p,h.content=s,d&&n.push(["title",d])),e.pos=u,e.posMax=x,!0}});var Cu=re((fy,Su)=>{"use strict";var qh=/^([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])?)*)$/,Vh=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;Su.exports=function(e,t){var n,o,s,i,a,l,u=e.pos;if(e.src.charCodeAt(u)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++u>=l||(i=e.src.charCodeAt(u),i===60))return!1;if(i===62)break}return n=e.src.slice(a+1,u),Vh.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):qh.test(n)?(o=e.md.normalizeLink("mailto:"+n),e.md.validateLink(o)?(t||(s=e.push("link_open","a",1),s.attrs=[["href",o]],s.markup="autolink",s.info="auto",s=e.push("text","",0),s.content=e.md.normalizeLinkText(n),s=e.push("link_close","a",-1),s.markup="autolink",s.info="auto"),e.pos+=n.length+2,!0):!1):!1}});var ku=re((hy,Au)=>{"use strict";var Gh=Gi().HTML_TAG_RE;function Wh(r){return/^<a[>\s]/i.test(r)}function Yh(r){return/^<\/a\s*>/i.test(r)}function Kh(r){var e=r|32;return e>=97&&e<=122}Au.exports=function(e,t){var n,o,s,i,a=e.pos;return!e.md.options.html||(s=e.posMax,e.src.charCodeAt(a)!==60||a+2>=s)||(n=e.src.charCodeAt(a+1),n!==33&&n!==63&&n!==47&&!Kh(n))||(o=e.src.slice(a).match(Gh),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length),Wh(i.content)&&e.linkLevel++,Yh(i.content)&&e.linkLevel--),e.pos+=o[0].length,!0)}});var Lu=re((py,Du)=>{"use strict";var Tu=_i(),Xh=_e().has,Zh=_e().isValidEntityCode,Iu=_e().fromCodePoint,Qh=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Jh=/^&([a-z][a-z0-9]{1,31});/i;Du.exports=function(e,t){var n,o,s,i,a=e.pos,l=e.posMax;if(e.src.charCodeAt(a)!==38||a+1>=l)return!1;if(n=e.src.charCodeAt(a+1),n===35){if(s=e.src.slice(a).match(Qh),s)return t||(o=s[1][0].toLowerCase()==="x"?parseInt(s[1].slice(1),16):parseInt(s[1],10),i=e.push("text_special","",0),i.content=Zh(o)?Iu(o):Iu(65533),i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(Jh),s&&Xh(Tu,s[1]))return t||(i=e.push("text_special","",0),i.content=Tu[s[1]],i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0;return!1}});var Ou=re((my,Ru)=>{"use strict";function Fu(r,e){var t,n,o,s,i,a,l,u,c={},f=e.length;if(!!f){var d=0,h=-2,p=[];for(t=0;t<f;t++)if(o=e[t],p.push(0),(e[d].marker!==o.marker||h!==o.token-1)&&(d=t),h=o.token,o.length=o.length||0,!!o.close){for(c.hasOwnProperty(o.marker)||(c[o.marker]=[-1,-1,-1,-1,-1,-1]),i=c[o.marker][(o.open?3:0)+o.length%3],n=d-p[d]-1,a=n;n>i;n-=p[n]+1)if(s=e[n],s.marker===o.marker&&s.open&&s.end<0&&(l=!1,(s.close||o.open)&&(s.length+o.length)%3===0&&(s.length%3!==0||o.length%3!==0)&&(l=!0),!l)){u=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+u,p[n]=u,o.open=!1,s.end=t,s.close=!1,a=-1,h=-2;break}a!==-1&&(c[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Ru.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(Fu(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&Fu(e,n[t].delimiters)}});var Mu=re((gy,Pu)=>{"use strict";Pu.exports=function(e){var t,n,o=0,s=e.tokens,i=e.tokens.length;for(t=n=0;t<i;t++)s[t].nesting<0&&o--,s[t].level=o,s[t].nesting>0&&o++,s[t].type==="text"&&t+1<i&&s[t+1].type==="text"?s[t+1].content=s[t].content+s[t+1].content:(t!==n&&(s[n]=s[t]),n++);t!==n&&(s.length=n)}});var Uu=re((vy,$u)=>{"use strict";var to=kn(),_u=_e().isWhiteSpace,Nu=_e().isPunctChar,Bu=_e().isMdAsciiPunct;function Ur(r,e,t,n){this.src=r,this.env=t,this.md=e,this.tokens=n,this.tokens_meta=Array(n.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}Ur.prototype.pushPending=function(){var r=new to("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};Ur.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new to(r,e,t),o=null;return t<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,t>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],o={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(o),n};Ur.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,u,c,f,d=!0,h=!0,p=this.posMax,g=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===g;)t++;return s=t-r,o=t<p?this.src.charCodeAt(t):32,u=Bu(n)||Nu(String.fromCharCode(n)),f=Bu(o)||Nu(String.fromCharCode(o)),l=_u(n),c=_u(o),c?d=!1:f&&(l||u||(d=!1)),l?h=!1:u&&(c||f||(h=!1)),e?(i=d,a=h):(i=d&&(!h||u),a=h&&(!d||f)),{can_open:i,can_close:a,length:s}};Ur.prototype.Token=to;$u.exports=Ur});var Hu=re((yy,ju)=>{"use strict";var zu=Cn(),ro=[["text",lu()],["linkify",cu()],["newline",fu()],["escape",pu()],["backticks",gu()],["strikethrough",Xi().tokenize],["emphasis",Qi().tokenize],["link",xu()],["image",Eu()],["autolink",Cu()],["html_inline",ku()],["entity",Lu()]],no=[["balance_pairs",Ou()],["strikethrough",Xi().postProcess],["emphasis",Qi().postProcess],["fragments_join",Mu()]];function zr(){var r;for(this.ruler=new zu,r=0;r<ro.length;r++)this.ruler.push(ro[r][0],ro[r][1]);for(this.ruler2=new zu,r=0;r<no.length;r++)this.ruler2.push(no[r][0],no[r][1])}zr.prototype.skipToken=function(r){var e,t,n=r.pos,o=this.ruler.getRules(""),s=o.length,i=r.md.options.maxNesting,a=r.cache;if(typeof a[n]<"u"){r.pos=a[n];return}if(r.level<i)for(t=0;t<s&&(r.level++,e=o[t](r,!0),r.level--,!e);t++);else r.pos=r.posMax;e||r.pos++,a[n]=r.pos};zr.prototype.tokenize=function(r){for(var e,t,n=this.ruler.getRules(""),o=n.length,s=r.posMax,i=r.md.options.maxNesting;r.pos<s;){if(r.level<i)for(t=0;t<o&&(e=n[t](r,!1),!e);t++);if(e){if(r.pos>=s)break;continue}r.pending+=r.src[r.pos++]}r.pending&&r.pushPending()};zr.prototype.parse=function(r,e,t,n){var o,s,i,a=new this.State(r,e,t,n);for(this.tokenize(a),s=this.ruler2.getRules(""),i=s.length,o=0;o<i;o++)s[o](a)};zr.prototype.State=Uu();ju.exports=zr});var Vu=re((by,qu)=>{"use strict";qu.exports=function(r){var e={};r=r||{},e.src_Any=Bi().source,e.src_Cc=$i().source,e.src_Z=Ui().source,e.src_P=bn().source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");var t="[><\uFF5C]";return e.src_pseudo_letter="(?:(?!"+t+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+t+"|"+e.src_ZPCc+")(?!"+(r["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+t+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(r["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+t+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`|\uFF5C]|"+e.src_ZPCc+"))((?![$+<=>^`|\uFF5C])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}});var Xu=re((xy,Ku)=>{"use strict";function io(r){var e=Array.prototype.slice.call(arguments,1);return e.forEach(function(t){!t||Object.keys(t).forEach(function(n){r[n]=t[n]})}),r}function Rn(r){return Object.prototype.toString.call(r)}function ep(r){return Rn(r)==="[object String]"}function tp(r){return Rn(r)==="[object Object]"}function rp(r){return Rn(r)==="[object RegExp]"}function Gu(r){return Rn(r)==="[object Function]"}function np(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var Yu={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function ip(r){return Object.keys(r||{}).reduce(function(e,t){return e||Yu.hasOwnProperty(t)},!1)}var op={"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}}},sp="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]",ap="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function lp(r){r.__index__=-1,r.__text_cache__=""}function up(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function Wu(){return function(r,e){e.normalize(r)}}function Fn(r){var e=r.re=Vu()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(sp),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,tp(l)){rp(l.validate)?u.validate=up(l.validate):Gu(l.validate)?u.validate=l.validate:s(a,l),Gu(l.normalize)?u.normalize=l.normalize:l.normalize?s(a,l):u.normalize=Wu();return}if(ep(l)){o.push(a);return}s(a,l)}}),o.forEach(function(a){!r.__compiled__[r.__schemas__[a]]||(r.__compiled__[a].validate=r.__compiled__[r.__schemas__[a]].validate,r.__compiled__[a].normalize=r.__compiled__[r.__schemas__[a]].normalize)}),r.__compiled__[""]={validate:null,normalize:Wu()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(np).join("|");r.re.schema_test=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+i+")","i"),r.re.schema_search=RegExp("(^|(?!_)(?:[><\uFF5C]|"+e.src_ZPCc+"))("+i+")","ig"),r.re.schema_at_start=RegExp("^"+r.re.schema_search.source,"i"),r.re.pretest=RegExp("("+r.re.schema_test.source+")|("+r.re.host_fuzzy_test.source+")|@","i"),lp(r)}function cp(r,e){var t=r.__index__,n=r.__last_index__,o=r.__text_cache__.slice(t,n);this.schema=r.__schema__.toLowerCase(),this.index=t+e,this.lastIndex=n+e,this.raw=o,this.text=o,this.url=o}function oo(r,e){var t=new cp(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function yt(r,e){if(!(this instanceof yt))return new yt(r,e);e||ip(r)&&(e=r,r={}),this.__opts__=io({},Yu,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=io({},op,r),this.__compiled__={},this.__tlds__=ap,this.__tlds_replaced__=!1,this.re={},Fn(this)}yt.prototype.add=function(e,t){return this.__schemas__[e]=t,Fn(this),this};yt.prototype.set=function(e){return this.__opts__=io(this.__opts__,e),this};yt.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,o,s,i,a,l,u,c;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(s=this.testSchemaAt(e,t[2],l.lastIndex),s){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+s;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(u=e.search(this.re.host_fuzzy_test),u>=0&&(this.__index__<0||u<this.__index__)&&(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(i=n.index+n[1].length,(this.__index__<0||i<this.__index__)&&(this.__schema__="",this.__index__=i,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(c=e.indexOf("@"),c>=0&&(o=e.match(this.re.email_fuzzy))!==null&&(i=o.index+o[1].length,a=o.index+o[0].length,(this.__index__<0||i<this.__index__||i===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=a))),this.__index__>=0};yt.prototype.pretest=function(e){return this.re.pretest.test(e)};yt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};yt.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(oo(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(oo(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};yt.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;var t=this.re.schema_at_start.exec(e);if(!t)return null;var n=this.testSchemaAt(e,t[2],t[0].length);return n?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+n,oo(this,0)):null};yt.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(n,o,s){return n!==s[o-1]}).reverse(),Fn(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Fn(this),this)};yt.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};yt.prototype.onCompile=function(){};Ku.exports=yt});var ic={};Md(ic,{decode:()=>uo,default:()=>yp,encode:()=>co,toASCII:()=>nc,toUnicode:()=>rc,ucs2decode:()=>lo,ucs2encode:()=>ec});function rr(r){throw new RangeError(pp[r])}function mp(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function Ju(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(hp,".");let o=r.split("."),s=mp(o,e).join(".");return n+s}function lo(r){let e=[],t=0,n=r.length;for(;t<n;){let o=r.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){let s=r.charCodeAt(t++);(s&64512)==56320?e.push(((o&1023)<<10)+(s&1023)+65536):(e.push(o),t--)}else e.push(o)}return e}var Qu,dp,fp,hp,pp,so,Mt,ao,ec,gp,Zu,tc,uo,co,rc,nc,vp,yp,oc=Pd(()=>{"use strict";Qu="-",dp=/^xn--/,fp=/[^\0-\x7E]/,hp=/[\x2E\u3002\uFF0E\uFF61]/g,pp={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},so=36-1,Mt=Math.floor,ao=String.fromCharCode;ec=r=>String.fromCodePoint(...r),gp=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36},Zu=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},tc=function(r,e,t){let n=0;for(r=t?Mt(r/700):r>>1,r+=Mt(r/e);r>so*26>>1;n+=36)r=Mt(r/so);return Mt(n+(so+1)*r/(r+38))},uo=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(Qu);i<0&&(i=0);for(let a=0;a<i;++a)r.charCodeAt(a)>=128&&rr("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a<t;){let l=n;for(let c=1,f=36;;f+=36){a>=t&&rr("invalid-input");let d=gp(r.charCodeAt(a++));(d>=36||d>Mt((2147483647-n)/c))&&rr("overflow"),n+=d*c;let h=f<=s?1:f>=s+26?26:f-s;if(d<h)break;let p=36-h;c>Mt(2147483647/p)&&rr("overflow"),c*=p}let u=e.length+1;s=tc(n-l,u,l==0),Mt(n/u)>2147483647-o&&rr("overflow"),o+=Mt(n/u),n%=u,e.splice(n++,0,o)}return String.fromCodePoint(...e)},co=function(r){let e=[];r=lo(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(ao(l));let i=e.length,a=i;for(i&&e.push(Qu);a<t;){let l=2147483647;for(let c of r)c>=n&&c<l&&(l=c);let u=a+1;l-n>Mt((2147483647-o)/u)&&rr("overflow"),o+=(l-n)*u,n=l;for(let c of r)if(c<n&&++o>2147483647&&rr("overflow"),c==n){let f=o;for(let d=36;;d+=36){let h=d<=s?1:d>=s+26?26:d-s;if(f<h)break;let p=f-h,g=36-h;e.push(ao(Zu(h+p%g,0))),f=Mt(p/g)}e.push(ao(Zu(f,0))),s=tc(o,u,a==i),o=0,++a}++o,++n}return e.join("")},rc=function(r){return Ju(r,function(e){return dp.test(e)?uo(e.slice(4).toLowerCase()):e})},nc=function(r){return Ju(r,function(e){return fp.test(e)?"xn--"+co(e):e})},vp={version:"2.1.0",ucs2:{decode:lo,encode:ec},decode:uo,encode:co,toASCII:nc,toUnicode:rc},yp=vp});var ac=re((wy,sc)=>{"use strict";sc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}}});var uc=re((Ey,lc)=>{"use strict";lc.exports={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}}});var dc=re((Sy,cc)=>{"use strict";cc.exports={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"\u201C\u201D\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}});var mc=re((Cy,pc)=>{"use strict";var jr=_e(),bp=Ya(),xp=Xa(),wp=Sl(),Ep=su(),Sp=Hu(),Cp=Xu(),nr=Ni(),fc=(oc(),_d(ic)),Ap={default:ac(),zero:uc(),commonmark:dc()},kp=/^(vbscript|javascript|file|data):/,Tp=/^data:image\/(gif|png|jpeg|webp);/;function Ip(r){var e=r.trim().toLowerCase();return kp.test(e)?!!Tp.test(e):!0}var hc=["http:","https:","mailto:"];function Dp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toASCII(e.hostname)}catch{}return nr.encode(nr.format(e))}function Lp(r){var e=nr.parse(r,!0);if(e.hostname&&(!e.protocol||hc.indexOf(e.protocol)>=0))try{e.hostname=fc.toUnicode(e.hostname)}catch{}return nr.decode(nr.format(e),nr.decode.defaultChars+"%")}function St(r,e){if(!(this instanceof St))return new St(r,e);e||jr.isString(r)||(e=r||{},r="default"),this.inline=new Sp,this.block=new Ep,this.core=new wp,this.renderer=new xp,this.linkify=new Cp,this.validateLink=Ip,this.normalizeLink=Dp,this.normalizeLinkText=Lp,this.utils=jr,this.helpers=jr.assign({},bp),this.options={},this.configure(r),e&&this.set(e)}St.prototype.set=function(r){return jr.assign(this.options,r),this};St.prototype.configure=function(r){var e=this,t;if(jr.isString(r)&&(t=r,r=Ap[t],!r))throw new Error('Wrong `markdown-it` preset "'+t+'", check name');if(!r)throw new Error("Wrong `markdown-it` preset, can't be empty");return r.options&&e.set(r.options),r.components&&Object.keys(r.components).forEach(function(n){r.components[n].rules&&e[n].ruler.enableOnly(r.components[n].rules),r.components[n].rules2&&e[n].ruler2.enableOnly(r.components[n].rules2)}),this};St.prototype.enable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(o){t=t.concat(this[o].ruler.enable(r,!0))},this),t=t.concat(this.inline.ruler2.enable(r,!0));var n=r.filter(function(o){return t.indexOf(o)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this};St.prototype.disable=function(r,e){var t=[];Array.isArray(r)||(r=[r]),["core","block","inline"].forEach(function(o){t=t.concat(this[o].ruler.disable(r,!0))},this),t=t.concat(this.inline.ruler2.disable(r,!0));var n=r.filter(function(o){return t.indexOf(o)<0});if(n.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this};St.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};St.prototype.parse=function(r,e){if(typeof r!="string")throw new Error("Input data should be a String");var t=new this.core.State(r,this,e);return this.core.process(t),t.tokens};St.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};St.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};St.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};pc.exports=St});var vc=re((Ay,gc)=>{"use strict";gc.exports=mc()});var Ec=re((ky,wc)=>{var fo=!0,bc=!1,xc=!1;wc.exports=function(r,e){e&&(fo=!e.enabled,bc=!!e.label,xc=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o<n.length;o++)Rp(n,o)&&(Op(n[o],t.Token),yc(n[o-2],"class","task-list-item"+(fo?"":" enabled")),yc(n[Fp(n,o-2)],"class","contains-task-list"))})};function yc(r,e,t){var n=r.attrIndex(e),o=[e,t];n<0?r.attrPush(o):r.attrs[n]=o}function Fp(r,e){for(var t=r[e].level-1,n=e-1;n>=0;n--)if(r[n].level===t)return n;return-1}function Rp(r,e){return Bp(r[e])&&$p(r[e-1])&&Up(r[e-2])&&zp(r[e])}function Op(r,e){if(r.children.unshift(Pp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),bc)if(xc){r.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);r.children[0].content=r.children[0].content.slice(0,-1)+' id="'+t+'">',r.children.push(Np(r.content,t,e))}else r.children.unshift(Mp(e)),r.children.push(_p(e))}function Pp(r,e){var t=new e("html_inline","",0),n=fo?' disabled="" ':"";return r.content.indexOf("[ ] ")===0?t.content='<input class="task-list-item-checkbox"'+n+'type="checkbox">':(r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0)&&(t.content='<input class="task-list-item-checkbox" checked=""'+n+'type="checkbox">'),t}function Mp(r){var e=new r("html_inline","",0);return e.content="<label>",e}function _p(r){var e=new r("html_inline","",0);return e.content="</label>",e}function Np(r,e,t){var n=new t("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+e+'">'+r+"</label>",n.attrs=[{for:e}],n}function Bp(r){return r.type==="inline"}function $p(r){return r.type==="paragraph_open"}function Up(r){return r.type==="list_item_open"}function zp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var _c=re((Gr,Io)=>{(function(r,e){typeof Gr=="object"&&typeof Io=="object"?Io.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Gr=="object"?Gr.ClipboardJS=e():r.ClipboardJS=e()})(Gr,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return C}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),u=s.n(l);function c(P){try{return document.execCommand(P)}catch{return}}var f=function(P){return P=u()(P),c("cut"),P};function d(M,A){var D,I,M=(D=M,I=document.documentElement.getAttribute("dir")==="rtl",(M=document.createElement("textarea")).style.fontSize="12pt",M.style.border="0",M.style.padding="0",M.style.margin="0",M.style.position="absolute",M.style[I?"right":"left"]="-9999px",I=window.pageYOffset||document.documentElement.scrollTop,M.style.top="".concat(I,"px"),M.setAttribute("readonly",""),M.value=D,M);return A.container.appendChild(M),A=u()(M),c("copy"),M.remove(),A}var h=function(P){var A=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof P=="string"?D=d(P,A):P instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(P?.type)?D=d(P.value,A):(D=u()(P),c("copy")),D};function p(P){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(P)}var g=function(){var I=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=I.action,P=D===void 0?"copy":D,A=I.container,D=I.target,I=I.text;if(P!=="copy"&&P!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0){if(!D||p(D)!=="object"||D.nodeType!==1)throw new Error('Invalid "target" value, use a valid Element');if(P==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(P==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}return I?h(I,{container:A}):D?P==="cut"?f(D):h(D,{container:A}):void 0};function y(P){return(y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(P)}function b(P,A){for(var D=0;D<A.length;D++){var I=A[D];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(P,I.key,I)}}function x(P,A){return(x=Object.setPrototypeOf||function(D,I){return D.__proto__=I,D})(P,A)}function k(P){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var D,I=S(P);return D=A?(D=S(this).constructor,Reflect.construct(I,arguments,D)):I.apply(this,arguments),I=this,!(D=D)||y(D)!=="object"&&typeof D!="function"?function(M){if(M!==void 0)return M;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(I):D}}function S(P){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(P)}function O(P,A){if(P="data-clipboard-".concat(P),A.hasAttribute(P))return A.getAttribute(P)}var C=function(){(function(N,B){if(typeof B!="function"&&B!==null)throw new TypeError("Super expression must either be null or a function");N.prototype=Object.create(B&&B.prototype,{constructor:{value:N,writable:!0,configurable:!0}}),B&&x(N,B)})(M,i());var P,A,D,I=k(M);function M(N,B){var H;return function(Z){if(!(Z instanceof M))throw new TypeError("Cannot call a class as a function")}(this),(H=I.call(this)).resolveOptions(B),H.listenClick(N),H}return P=M,D=[{key:"copy",value:function(N){var B=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return h(N,B)}},{key:"cut",value:function(N){return f(N)}},{key:"isSupported",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],N=typeof N=="string"?[N]:N,B=!!document.queryCommandSupported;return N.forEach(function(H){B=B&&!!document.queryCommandSupported(H)}),B}}],(A=[{key:"resolveOptions",value:function(){var N=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=y(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var B=this;this.listener=a()(N,"click",function(H){return B.onClick(H)})}},{key:"onClick",value:function(Z){var B=Z.delegateTarget||Z.currentTarget,H=this.action(B)||"copy",Z=g({action:H,container:this.container,target:this.target(B),text:this.text(B)});this.emit(Z?"success":"error",{action:H,text:Z,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return O("action",N)}},{key:"defaultTarget",value:function(N){if(N=O("target",N),N)return document.querySelector(N)}},{key:"defaultText",value:function(N){return O("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(P.prototype,A),D&&b(P,D),M}()},828:function(n){var o;typeof Element>"u"||Element.prototype.matches||((o=Element.prototype).matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector),n.exports=function(s,i){for(;s&&s.nodeType!==9;){if(typeof s.matches=="function"&&s.matches(i))return s;s=s.parentNode}}},438:function(n,o,s){var i=s(828);function a(l,u,c,f,d){var h=function(p,g,y,b){return function(x){x.delegateTarget=i(x.target,g),x.delegateTarget&&b.call(p,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 g=u,y=c,(p=l).addEventListener(g,y),{destroy:function(){p.removeEventListener(g,y)}};if(i.nodeList(l))return f=l,d=u,h=c,Array.prototype.forEach.call(f,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(f,function(b){b.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,p,g,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;l++)a[l].fn.apply(a[l].ctx,i);return this},off:function(s,i){var a=this.e||(this.e={}),l=a[s],u=[];if(l&&i)for(var c=0,f=l.length;c<f;c++)l[c].fn!==i&&l[c].fn._!==i&&u.push(l[c]);return u.length?a[s]=u:delete a[s],this}},n.exports=o,n.exports.TinyEmitter=o}},t={},r.n=function(n){var o=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(o,{a:o}),o},r.d=function(n,o){for(var s in o)r.o(o,s)&&!r.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:o[s]})},r.o=function(n,o){return Object.prototype.hasOwnProperty.call(n,o)},r(686).default;function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var e,t})});var Sr={},Nd=[];function Kr(r,e){if(Nd.push({name:r,data:e}),typeof Sr[r]>"u")return this;let t=Sr[r];for(let n=0;n<t.length;n++)t[n](e)}function Bd(r,e){typeof Sr[r]>"u"&&(Sr[r]=[]),Sr[r].push(e)}function $d(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function Ud(r){if(!!r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
-`);Kr("error",e)}}var Jo={emit:Kr,emitPublic:$d,listen:Bd,success:r=>Kr("success",r),error:r=>Kr("error",r),showValidationErrors:Ud};async function zd(r,e={}){return es(r,{method:"GET",params:e})}async function jd(r,e=null){return Xr("POST",r,e)}async function Hd(r,e=null){return Xr("PUT",r,e)}async function qd(r,e=null){return Xr("PATCH",r,e)}async function Vd(r,e=null){return Xr("DELETE",r,e)}async function Xr(r,e,t=null){let n={method:r,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(n.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},n.body=JSON.stringify(t)),t instanceof FormData&&r!=="post"&&(t.append("_method",r),n.method="post"),es(e,n)}async function es(r,e={}){if(r.startsWith("http")||(r=window.baseUrl(r)),e.params){let i=new URL(r);for(let a of Object.keys(e.params)){let l=e.params[a];typeof l<"u"&&l!==null&&i.searchParams.set(a,l)}r=i.toString()}let t=document.querySelector("meta[name=token]").getAttribute("content");e=Object.assign({},e,{credentials:"same-origin"}),e.headers=Object.assign({},e.headers||{},{baseURL:window.baseUrl(""),"X-CSRF-TOKEN":t});let n=await fetch(r,e),s={data:await Gd(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 Gd(r){if(r.status===204)return null;let t=(r.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?await r.json():await r.text()}var ts={get:zd,post:jd,put:Hd,patch:qd,delete:Vd};var Un=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),o=t.getAttribute("value");this.store.set(n,o)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let o=this.getTransText(e);return this.parsePlural(o,t,n)}parsePlural(e,t,n){let o=e.split("|"),s=/^{([0-9]+)}/,i=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let u=l.match(s);if(u!==null&&Number(u[1])===t){a=l.replace(s,"").trim();break}let c=l.match(i);if(c!==null&&Number(c[1])<=t&&(c[2]==="*"||Number(c[2])>=t)){a=l.replace(i,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,n)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let n=e.match(/:([\S]+)/g);return n===null||n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(e=e.replace(o,t[s]))}),e}},rs=Un;function Zr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Qr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Be(r,e){Array.isArray(r)||(r=[r]);for(let t of r)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function Jr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function We(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function ns(r,e){let t=document.querySelectorAll(r);e=e.toLowerCase();for(let n of t)if(n.textContent.toLowerCase().includes(e))return n;return null}function Cr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function is(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ar(r,e,t){let n;return function(){let o=this,s=arguments,i=function(){n=null,t||r.apply(o,s)},a=t&&!n;clearTimeout(n),n=setTimeout(i,e),a&&r.apply(o,s)}}function kr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=document.getElementById("custom-styles").getAttribute("data-color-light"),t=window.getComputedStyle(r).getPropertyValue("background-color");r.style.backgroundColor=e,setTimeout(()=>{r.classList.add("selectFade"),r.style.backgroundColor=t},10),setTimeout(()=>{r.classList.remove("selectFade"),r.style.backgroundColor=""},3e3)}function ss(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function as(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var zn=class{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),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=as(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},ls=zn;var jn=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Be(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}},us=jn;var Hn=class{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}Jr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Be(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}},cs=Hn;var qn=class{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})})}reloadList(){this.stopEdit(),this.mainTabs.components.tabs.show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.list.innerHTML=e.data,window.components.init(this.list)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),Cr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}},ds=qn;var Vn=class{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href=t.href+"?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}},fs=Vn;var Gn={},Wn=class{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()}),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.container.addEventListener("keydown",this.containerKeyDown.bind(this)),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(Gn[o])return Gn[o];let s=await window.$http.get(this.url,n);return Gn[o]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`<li><button type="button" class="text-item">${ss(t)}</button></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll("button"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}},hs=Wn;var Yn=class{constructor(e){if(this.elem=e,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.elem.style.display="none";return}this.elem.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.elem.style.display="block",this.showing=!0,setTimeout(()=>{this.elem.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.elem.style.opacity=0,this.showing=!1,setTimeout(()=>{this.elem.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,n=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function i(){let a=1-(Date.now()-o)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(i.bind(this))):t.scrollTop=e}requestAnimationFrame(i.bind(this))}},ps=Yn;function ms(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function Rt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ms(Object(t),!0).forEach(function(n){Wd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ms(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function on(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?on=function(e){return typeof e}:on=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(r)}function Wd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function jt(){return jt=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},jt.apply(this,arguments)}function Yd(r,e){if(r==null)return{};var t={},n=Object.keys(r),o,s;for(s=0;s<n.length;s++)o=n[s],!(e.indexOf(o)>=0)&&(t[o]=r[o]);return t}function Kd(r,e){if(r==null)return{};var t=Yd(r,e),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(o=0;o<s.length;o++)n=s[o],!(e.indexOf(n)>=0)&&(!Object.prototype.propertyIsEnumerable.call(r,n)||(t[n]=r[n]))}return t}var Xd="1.15.0";function zt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Ht=zt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Mr=zt(/Edge/i),gs=zt(/firefox/i),Lr=zt(/safari/i)&&!zt(/chrome/i)&&!zt(/android/i),Cs=zt(/iP(ad|od|hone)/i),As=zt(/chrome/i)&&zt(/android/i),ks={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!Ht&&ks)}function Le(r,e,t){r.removeEventListener(e,t,!Ht&&ks)}function cn(r,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),r)try{if(r.matches)return r.matches(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e)}catch{return!1}return!1}}function Zd(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Lt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&cn(r,e):cn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Zd(r))}return null}var vs=/\s+/g;function mt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(vs," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(vs," ")}}function ge(r,e,t){var n=r&&r.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(r,""):r.currentStyle&&(t=r.currentStyle),e===void 0?t:t[e];!(e in n)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),n[e]=t+(typeof t=="string"?"":"px")}}function dr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ge(r,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(r=r.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function Ts(r,e,t){if(r){var n=r.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o<s;o++)t(n[o],o);return n}return[]}function Ft(){var r=document.scrollingElement;return r||document.documentElement}function tt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,u,c,f;if(r!==window&&r.parentNode&&r!==Ft()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,u=s.right,c=s.height,f=s.width):(i=0,a=0,l=window.innerHeight,u=window.innerWidth,c=window.innerHeight,f=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!Ht))do if(o&&o.getBoundingClientRect&&(ge(o,"transform")!=="none"||t&&ge(o,"position")!=="static")){var d=o.getBoundingClientRect();i-=d.top+parseInt(ge(o,"border-top-width")),a-=d.left+parseInt(ge(o,"border-left-width")),l=i+s.height,u=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var h=dr(o||r),p=h&&h.a,g=h&&h.d;h&&(i/=g,a/=p,f/=p,c/=g,l=i+c,u=a+f)}return{top:i,left:a,bottom:l,right:u,width:f,height:c}}}function ys(r,e,t){for(var n=Kt(r,!0),o=tt(r)[e];n;){var s=tt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ft())break;n=Kt(n,!1)}return!1}function fr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ve.ghost&&(n||i[s]!==ve.dragged)&&Lt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function li(r,e){for(var t=r.lastElementChild;t&&(t===ve.ghost||ge(t,"display")==="none"||e&&!cn(t,e));)t=t.previousElementSibling;return t||null}function Et(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ve.clone&&(!e||cn(r,e))&&t++;return t}function bs(r){var e=0,t=0,n=Ft();if(r)do{var o=dr(r),s=o.a,i=o.d;e+=r.scrollLeft*s,t+=r.scrollTop*i}while(r!==n&&(r=r.parentNode));return[e,t]}function Qd(r,e){for(var t in r)if(!!r.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r[t][n])return Number(t)}return-1}function Kt(r,e){if(!r||!r.getBoundingClientRect)return Ft();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ge(t);if(t.clientWidth<t.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Ft();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ft()}function Jd(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Kn(r,e){return Math.round(r.top)===Math.round(e.top)&&Math.round(r.left)===Math.round(e.left)&&Math.round(r.height)===Math.round(e.height)&&Math.round(r.width)===Math.round(e.width)}var Fr;function Is(r,e){return function(){if(!Fr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Fr=setTimeout(function(){Fr=void 0},e)}}}function ef(){clearTimeout(Fr),Fr=void 0}function Ds(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Ls(r){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(r).cloneNode(!0):t?t(r).clone(!0)[0]:r.cloneNode(!0)}var vt="Sortable"+new Date().getTime();function tf(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ge(o,"display")==="none"||o===ve.ghost)){r.push({target:o,rect:tt(o)});var s=Rt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=dr(o,!0);i&&(s.top-=i.f,s.left-=i.e)}o.fromRect=s}})}},addAnimationState:function(n){r.push(n)},removeAnimationState:function(n){r.splice(Qd(r,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,i=0;r.forEach(function(a){var l=0,u=a.target,c=u.fromRect,f=tt(u),d=u.prevFromRect,h=u.prevToRect,p=a.rect,g=dr(u,!0);g&&(f.top-=g.f,f.left-=g.e),u.toRect=f,u.thisAnimationDuration&&Kn(d,f)&&!Kn(c,f)&&(p.top-f.top)/(p.left-f.left)===(c.top-f.top)/(c.left-f.left)&&(l=nf(p,d,h,o.options)),Kn(f,c)||(u.prevFromRect=c,u.prevToRect=f,l||(l=o.options.animation),o.animate(u,p,f,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(u.animationResetTimer),u.animationResetTimer=setTimeout(function(){u.animationTime=0,u.prevFromRect=null,u.fromRect=null,u.prevToRect=null,u.thisAnimationDuration=null},l),u.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof n=="function"&&n()},i):typeof n=="function"&&n(),r=[]},animate:function(n,o,s,i){if(i){ge(n,"transition",""),ge(n,"transform","");var a=dr(this.el),l=a&&a.a,u=a&&a.d,c=(o.left-s.left)/(l||1),f=(o.top-s.top)/(u||1);n.animatingX=!!c,n.animatingY=!!f,ge(n,"transform","translate3d("+c+"px,"+f+"px,0)"),this.forRepaintDummy=rf(n),ge(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ge(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ge(n,"transition",""),ge(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function rf(r){return r.offsetWidth}function nf(r,e,t,n){return Math.sqrt(Math.pow(e.top-r.top,2)+Math.pow(e.left-r.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var ar=[],Xn={initializeByDefault:!0},_r={mount:function(e){for(var t in Xn)Xn.hasOwnProperty(t)&&!(t in e)&&(e[t]=Xn[t]);ar.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ar.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";ar.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Rt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Rt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){ar.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var u=new a(e,t,e.options);u.sortable=e,u.options=e.options,e[l]=u,jt(n,u.defaults)}});for(var s in e.options)if(!!e.options.hasOwnProperty(s)){var i=this.modifyOption(e,s,e.options[s]);typeof i<"u"&&(e.options[s]=i)}},getEventProperties:function(e,t){var n={};return ar.forEach(function(o){typeof o.eventProperties=="function"&&jt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return ar.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function of(r){var e=r.sortable,t=r.rootEl,n=r.name,o=r.targetEl,s=r.cloneEl,i=r.toEl,a=r.fromEl,l=r.oldIndex,u=r.newIndex,c=r.oldDraggableIndex,f=r.newDraggableIndex,d=r.originalEvent,h=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[vt],!!e){var g,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Ht&&!Mr?g=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent(n,!0,!0)),g.to=i||t,g.from=a||t,g.item=o||t,g.clone=s,g.oldIndex=l,g.newIndex=u,g.oldDraggableIndex=c,g.newDraggableIndex=f,g.originalEvent=d,g.pullMode=h?h.lastPutMode:void 0;var x=Rt(Rt({},p),_r.getEventProperties(n,e));for(var k in x)g[k]=x[k];t&&t.dispatchEvent(g),y[b]&&y[b].call(e,g)}}var sf=["evt"],ht=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Kd(n,sf);_r.pluginEvent.bind(ve)(e,t,Rt({dragEl:ee,parentEl:Ze,ghostEl:we,rootEl:qe,nextEl:er,lastDownEl:sn,cloneEl:Ye,cloneHidden:Yt,dragStarted:Tr,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt,hideGhostForTarget:Ps,unhideGhostForTarget:Ms,cloneNowHidden:function(){Yt=!0},cloneNowShown:function(){Yt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){of(Rt({putSortable:it,cloneEl:Ye,targetEl:ee,rootEl:qe,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt},r))}var ee,Ze,we,qe,er,sn,Ye,Yt,cr,gt,Rr,Wt,en,it,ur=!1,dn=!1,fn=[],Qt,At,Zn,Qn,xs,ws,Tr,lr,Or,Pr=!1,tn=!1,an,lt,Jn=[],ii=!1,hn=[],mn=typeof document<"u",rn=Cs,Es=Mr||Ht?"cssFloat":"float",af=mn&&!As&&!Cs&&"draggable"in document.createElement("div"),Fs=function(){if(!!mn){if(Ht)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Rs=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=fr(e,0,t),i=fr(e,1,t),a=s&&ge(s),l=i&&ge(i),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+tt(s).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+tt(i).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var f=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===f)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=o&&n[Es]==="none"||i&&n[Es]==="none"&&u+c>o)?"vertical":"horizontal"},lf=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},uf=function(e,t){var n;return fn.some(function(o){var s=o[vt].options.emptyInsertThreshold;if(!(!s||li(o))){var i=tt(o),a=e>=i.left-s&&e<=i.right+s,l=t>=i.top-s&&t<=i.bottom+s;if(a&&l)return n=o}}),n},Os=function(e){function t(s,i){return function(a,l,u,c){var f=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||f))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,u,c),i)(a,l,u,c);var 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||on(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=t(o.pull,!0),n.checkPut=t(o.put),n.revertClone=o.revertClone,e.group=n},Ps=function(){!Fs&&we&&ge(we,"display","none")},Ms=function(){!Fs&&we&&ge(we,"display","")};mn&&!As&&document.addEventListener("click",function(r){if(dn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),dn=!1,!1},!0);var Jt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=uf(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[vt]._onDragOver(n)}}},cf=function(e){ee&&ee.parentNode[vt]._isOutsideThisEl(e.target)};function ve(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=jt({},e),r[vt]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(r.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Rs(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(i,a){i.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ve.supportPointer!==!1&&"PointerEvent"in window&&!Lr,emptyInsertThreshold:5};_r.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);Os(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:af,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Me(r,"pointerdown",this._onTapStart):(Me(r,"mousedown",this._onTapStart),Me(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(Me(r,"dragover",this),Me(r,"dragenter",this)),fn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),jt(this,tf())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(lr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,ee):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,u=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=o.filter;if(yf(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Lr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Lt(l,o.draggable,n,!1),!(l&&l.animated)&&sn!==l)){if(cr=Et(l),Rr=Et(l,o.draggable),typeof c=="function"){if(c.call(this,e,l,this)){ct({sortable:t,rootEl:u,name:"filter",targetEl:l,toEl:n,fromEl:n}),ht("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(c&&(c=c.split(",").some(function(f){if(f=Lt(u,f.trim(),n,!1),f)return ct({sortable:t,rootEl:f,name:"filter",targetEl:l,fromEl:n,toEl:n}),ht("filter",t,{evt:e}),!0}),c)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Lt(u,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,i=o.options,a=s.ownerDocument,l;if(n&&!ee&&n.parentNode===s){var u=tt(n);if(qe=s,ee=n,Ze=ee.parentNode,er=ee.nextSibling,sn=n,en=i.group,ve.dragged=ee,Qt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},xs=Qt.clientX-u.left,ws=Qt.clientY-u.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,ee.style["will-change"]="all",l=function(){if(ht("delayEnded",o,{evt:e}),ve.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!gs&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),mt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){Ts(ee,c.trim(),ei)}),Me(a,"dragover",Jt),Me(a,"mousemove",Jt),Me(a,"touchmove",Jt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),gs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Mr||Ht))){if(ve.eventCanceled){this._onDrop();return}Me(a,"mouseup",o._disableDelayedDrag),Me(a,"touchend",o._disableDelayedDrag),Me(a,"touchcancel",o._disableDelayedDrag),Me(a,"mousemove",o._delayedDragTouchMoveHandler),Me(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&Me(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,i.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ee&&ei(ee),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._disableDelayedDrag),Le(e,"touchend",this._disableDelayedDrag),Le(e,"touchcancel",this._disableDelayedDrag),Le(e,"mousemove",this._delayedDragTouchMoveHandler),Le(e,"touchmove",this._delayedDragTouchMoveHandler),Le(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Me(document,"pointermove",this._onTouchMove):t?Me(document,"touchmove",this._onTouchMove):Me(document,"mousemove",this._onTouchMove):(Me(ee,"dragend",this),Me(qe,"dragstart",this._onDragStart));try{document.selection?ln(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ur=!1,qe&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",cf);var n=this.options;!e&&mt(ee,n.dragClass,!1),mt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(At){this._lastX=At.clientX,this._lastY=At.clientY,Ps();for(var e=document.elementFromPoint(At.clientX,At.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(At.clientX,At.clientY),e!==t);)t=e;if(ee.parentNode[vt]._isOutsideThisEl(e),t)do{if(t[vt]){var n=void 0;if(n=t[vt]._onDragOver({clientX:At.clientX,clientY:At.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ms()}},_onTouchMove:function(e){if(Qt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&dr(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=rn&<&&bs(lt),c=(s.clientX-Qt.clientX+o.x)/(a||1)+(u?u[0]-Jn[0]:0)/(a||1),f=(s.clientY-Qt.clientY+o.y)/(l||1)+(u?u[1]-Jn[1]:0)/(l||1);if(!ve.active&&!ur){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(we){i?(i.e+=c-(Zn||0),i.f+=f-(Qn||0)):i={a:1,b:0,c:0,d:1,e:c,f};var d="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ge(we,"webkitTransform",d),ge(we,"mozTransform",d),ge(we,"msTransform",d),ge(we,"transform",d),Zn=c,Qn=f,At=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!we){var e=this.options.fallbackOnBody?document.body:qe,t=tt(ee,!0,rn,!0,e),n=this.options;if(rn){for(lt=e;ge(lt,"position")==="static"&&ge(lt,"transform")==="none"&<!==document;)lt=lt.parentNode;lt!==document.body&<!==document.documentElement?(lt===document&&(lt=Ft()),t.top+=lt.scrollTop,t.left+=lt.scrollLeft):lt=Ft(),Jn=bs(lt)}we=ee.cloneNode(!0),mt(we,n.ghostClass,!1),mt(we,n.fallbackClass,!0),mt(we,n.dragClass,!0),ge(we,"transition",""),ge(we,"transform",""),ge(we,"box-sizing","border-box"),ge(we,"margin",0),ge(we,"top",t.top),ge(we,"left",t.left),ge(we,"width",t.width),ge(we,"height",t.height),ge(we,"opacity","0.8"),ge(we,"position",rn?"absolute":"fixed"),ge(we,"zIndex","100000"),ge(we,"pointerEvents","none"),ve.ghost=we,e.appendChild(we),ge(we,"transform-origin",xs/parseInt(we.style.width)*100+"% "+ws/parseInt(we.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(ht("dragStart",this,{evt:e}),ve.eventCanceled){this._onDrop();return}ht("setupClone",this),ve.eventCanceled||(Ye=Ls(ee),Ye.removeAttribute("id"),Ye.draggable=!1,Ye.style["will-change"]="",this._hideClone(),mt(Ye,this.options.chosenClass,!1),ve.clone=Ye),n.cloneId=ln(function(){ht("clone",n),!ve.eventCanceled&&(n.options.removeCloneOnHide||qe.insertBefore(Ye,ee),n._hideClone(),ct({sortable:n,name:"clone"}))}),!t&&mt(ee,s.dragClass,!0),t?(dn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Le(document,"mouseup",n._onDrop),Le(document,"touchend",n._onDrop),Le(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,ee)),Me(document,"drop",n),ge(ee,"transform","translateZ(0)")),ur=!0,n._dragStartId=ln(n._dragStarted.bind(n,t,e)),Me(document,"selectstart",n),Tr=!0,Lr&&ge(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,u=ve.active,c=en===l,f=a.sort,d=it||u,h,p=this,g=!1;if(ii)return;function y(ne,be){ht(ne,p,Rt({evt:e,isOwner:c,axis:h?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:f,fromSortable:d,target:n,completed:x,onMove:function(xe,Fe){return nn(qe,t,ee,o,xe,tt(xe),e,Fe)},changed:k},be))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==d&&d.captureAnimationState()}function x(ne){return y("dragOverCompleted",{insertion:ne}),ne&&(c?u._hideClone():u._showClone(p),p!==d&&(mt(ee,it?it.options.ghostClass:u.options.ghostClass,!1),mt(ee,a.ghostClass,!0)),it!==p&&p!==ve.active?it=p:p===ve.active&&it&&(it=null),d===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(n===ee&&!ee.animated||n===t&&!n.animated)&&(lr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(ee.parentNode[vt]._isOutsideThisEl(e.target),!ne&&Jt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),g=!0}function k(){gt=Et(ee),Wt=Et(ee,a.draggable),ct({sortable:p,name:"change",toEl:t,newIndex:gt,newDraggableIndex:Wt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Lt(n,a.draggable,t,!0),y("dragOver"),ve.eventCanceled)return g;if(ee.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(dn=!1,u&&!a.disabled&&(c?f||(i=Ze!==qe):it===this||(this.lastPutMode=en.checkPull(this,u,ee,e))&&l.checkPut(this,u,ee,e))){if(h=this._getDirection(e,n)==="vertical",o=tt(ee),y("dragOverValid"),ve.eventCanceled)return g;if(i)return Ze=qe,b(),this._hideClone(),y("revert"),ve.eventCanceled||(er?qe.insertBefore(ee,er):qe.appendChild(ee)),x(!0);var S=li(t,a.draggable);if(!S||pf(e,h,this)&&!S.animated){if(S===ee)return x(!1);if(S&&t===e.target&&(n=S),n&&(s=tt(n)),nn(qe,t,ee,o,n,s,e,!!n)!==!1)return b(),S&&S.nextSibling?t.insertBefore(ee,S.nextSibling):t.appendChild(ee),Ze=t,k(),x(!0)}else if(S&&hf(e,h,this)){var O=fr(t,0,a,!0);if(O===ee)return x(!1);if(n=O,s=tt(n),nn(qe,t,ee,o,n,s,e,!1)!==!1)return b(),t.insertBefore(ee,O),Ze=t,k(),x(!0)}else if(n.parentNode===t){s=tt(n);var C=0,P,A=ee.parentNode!==t,D=!lf(ee.animated&&ee.toRect||o,n.animated&&n.toRect||s,h),I=h?"top":"left",M=ys(n,"top","top")||ys(ee,"top","top"),N=M?M.scrollTop:void 0;lr!==n&&(P=s[I],Pr=!1,tn=!D&&a.invertSwap||A),C=mf(e,n,s,h,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,tn,lr===n);var B;if(C!==0){var H=Et(ee);do H-=C,B=Ze.children[H];while(B&&(ge(B,"display")==="none"||B===we))}if(C===0||B===n)return x(!1);lr=n,Or=C;var Z=n.nextElementSibling,W=!1;W=C===1;var te=nn(qe,t,ee,o,n,s,e,W);if(te!==!1)return(te===1||te===-1)&&(W=te===1),ii=!0,setTimeout(ff,30),b(),W&&!Z?t.appendChild(ee):n.parentNode.insertBefore(ee,W?Z:n),M&&Ds(M,0,N-M.scrollTop),Ze=ee.parentNode,P!==void 0&&!tn&&(an=Math.abs(P-tt(n)[I])),k(),x(!0)}if(t.contains(ee))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Le(document,"mousemove",this._onTouchMove),Le(document,"touchmove",this._onTouchMove),Le(document,"pointermove",this._onTouchMove),Le(document,"dragover",Jt),Le(document,"mousemove",Jt),Le(document,"touchmove",Jt)},_offUpEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._onDrop),Le(e,"touchend",this._onDrop),Le(e,"pointerup",this._onDrop),Le(e,"touchcancel",this._onDrop),Le(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(gt=Et(ee),Wt=Et(ee,n.draggable),ht("drop",this,{evt:e}),Ze=ee&&ee.parentNode,gt=Et(ee),Wt=Et(ee,n.draggable),ve.eventCanceled){this._nulling();return}ur=!1,tn=!1,Pr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),oi(this.cloneId),oi(this._dragStartId),this.nativeDraggable&&(Le(document,"drop",this),Le(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Lr&&ge(document.body,"user-select",""),ge(ee,"transform",""),e&&(Tr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),we&&we.parentNode&&we.parentNode.removeChild(we),(qe===Ze||it&&it.lastPutMode!=="clone")&&Ye&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),ee&&(this.nativeDraggable&&Le(ee,"dragend",this),ei(ee),ee.style["will-change"]="",Tr&&!ur&&mt(ee,it?it.options.ghostClass:this.options.ghostClass,!1),mt(ee,this.options.chosenClass,!1),ct({sortable:this,name:"unchoose",toEl:Ze,newIndex:null,newDraggableIndex:null,originalEvent:e}),qe!==Ze?(gt>=0&&(ct({rootEl:Ze,name:"add",toEl:Ze,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Ze,originalEvent:e}),ct({rootEl:Ze,name:"sort",toEl:Ze,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),it&&it.save()):gt!==cr&>>=0&&(ct({sortable:this,name:"update",toEl:Ze,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),ve.active&&((gt==null||gt===-1)&&(gt=cr,Wt=Rr),ct({sortable:this,name:"end",toEl:Ze,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),qe=ee=Ze=we=er=Ye=sn=Yt=Qt=At=Tr=gt=Wt=cr=Rr=lr=Or=it=en=ve.dragged=ve.ghost=ve.clone=ve.active=null,hn.forEach(function(e){e.checked=!0}),hn.length=Zn=Qn=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),df(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,o=0,s=n.length,i=this.options;o<s;o++)t=n[o],Lt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||vf(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Lt(a,this.options.draggable,o,!1)&&(n[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return Lt(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var o=_r.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&Os(n)},destroy:function(){ht("destroy",this);var e=this.el;e[vt]=null,Le(e,"mousedown",this._onTapStart),Le(e,"touchstart",this._onTapStart),Le(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Le(e,"dragover",this),Le(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),fn.splice(fn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Yt){if(ht("hideClone",this),ve.eventCanceled)return;ge(Ye,"display","none"),this.options.removeCloneOnHide&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),Yt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Yt){if(ht("showClone",this),ve.eventCanceled)return;ee.parentNode==qe&&!this.options.group.revertClone?qe.insertBefore(Ye,ee):er?qe.insertBefore(Ye,er):qe.appendChild(Ye),this.options.group.revertClone&&this.animate(ee,Ye),ge(Ye,"display",""),Yt=!1}}};function df(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function nn(r,e,t,n,o,s,i,a){var l,u=r[vt],c=u.options.onMove,f;return window.CustomEvent&&!Ht&&!Mr?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=r,l.dragged=t,l.draggedRect=n,l.related=o||e,l.relatedRect=s||tt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),c&&(f=c.call(u,l,i)),f}function ei(r){r.draggable=!1}function ff(){ii=!1}function hf(r,e,t){var n=tt(fr(t.el,0,t.options,!0)),o=10;return e?r.clientX<n.left-o||r.clientY<n.top&&r.clientX<n.right:r.clientY<n.top-o||r.clientY<n.bottom&&r.clientX<n.left}function pf(r,e,t){var n=tt(li(t.el,t.options.draggable)),o=10;return e?r.clientX>n.right+o||r.clientX<=n.right&&r.clientY>n.bottom&&r.clientX>=n.left:r.clientX>n.right&&r.clientY>n.top||r.clientX<=n.right&&r.clientY>n.bottom+o}function mf(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&&an<u*o){if(!Pr&&(Or===1?l>c+u*s/2:l<f-u*s/2)&&(Pr=!0),Pr)d=!0;else if(Or===1?l<c+an:l>f-an)return-Or}else if(l>c+u*(1-o)/2&&l<f-u*(1-o)/2)return gf(e)}return d=d||i,d&&(l<c+u*s/2||l>f-u*s/2)?l>c+u/2?1:-1:0}function gf(r){return Et(ee)<Et(r)?1:-1}function vf(r){for(var e=r.tagName+r.className+r.src+r.href+r.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function yf(r){hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&hn.push(n)}}function ln(r){return setTimeout(r,0)}function oi(r){return clearTimeout(r)}mn&&Me(document,"touchmove",function(r){(ve.active||ur)&&r.cancelable&&r.preventDefault()});ve.utils={on:Me,off:Le,css:ge,find:Ts,is:function(e,t){return!!Lt(e,t,e,!1)},extend:Jd,throttle:Is,closest:Lt,toggleClass:mt,clone:Ls,index:Et,nextTick:ln,cancelNextTick:oi,detectDirection:Rs,getChild:fr};ve.get=function(r){return r[vt]};ve.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(ve.utils=Rt(Rt({},ve.utils),n.utils)),_r.mount(n)})};ve.create=function(r,e){return new ve(r,e)};ve.version=Xd;var Je=[],Ir,si,ai=!1,ti,ri,pn,Dr;function bf(){function r(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return r.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?Me(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Me(document,"pointermove",this._handleFallbackAutoScroll):n.touches?Me(document,"touchmove",this._handleFallbackAutoScroll):Me(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Le(document,"dragover",this._handleAutoScroll):(Le(document,"pointermove",this._handleFallbackAutoScroll),Le(document,"touchmove",this._handleFallbackAutoScroll),Le(document,"mousemove",this._handleFallbackAutoScroll)),Ss(),un(),ef()},nulling:function(){pn=si=Ir=ai=Dr=ti=ri=null,Je.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var o=this,s=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(s,i);if(pn=t,n||this.options.forceAutoScrollFallback||Mr||Ht||Lr){ni(t,this.options,a,n);var l=Kt(a,!0);ai&&(!Dr||s!==ti||i!==ri)&&(Dr&&Ss(),Dr=setInterval(function(){var u=Kt(document.elementFromPoint(s,i),!0);u!==l&&(l=u,un()),ni(t,o.options,u,n)},10),ti=s,ri=i)}else{if(!this.options.bubbleScroll||Kt(a,!0)===Ft()){un();return}ni(t,this.options,Kt(a,!1),!1)}}},jt(r,{pluginName:"scroll",initializeByDefault:!0})}function un(){Je.forEach(function(r){clearInterval(r.pid)}),Je=[]}function Ss(){clearInterval(Dr)}var ni=Is(function(r,e,t,n){if(!!e.scroll){var o=(r.touches?r.touches[0]:r).clientX,s=(r.touches?r.touches[0]:r).clientY,i=e.scrollSensitivity,a=e.scrollSpeed,l=Ft(),u=!1,c;si!==t&&(si=t,un(),Ir=e.scroll,c=e.scrollFn,Ir===!0&&(Ir=Kt(t,!0)));var f=0,d=Ir;do{var h=d,p=tt(h),g=p.top,y=p.bottom,b=p.left,x=p.right,k=p.width,S=p.height,O=void 0,C=void 0,P=h.scrollWidth,A=h.scrollHeight,D=ge(h),I=h.scrollLeft,M=h.scrollTop;h===l?(O=k<P&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),C=S<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(O=k<P&&(D.overflowX==="auto"||D.overflowX==="scroll"),C=S<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var N=O&&(Math.abs(x-o)<=i&&I+k<P)-(Math.abs(b-o)<=i&&!!I),B=C&&(Math.abs(y-s)<=i&&M+S<A)-(Math.abs(g-s)<=i&&!!M);if(!Je[f])for(var H=0;H<=f;H++)Je[H]||(Je[H]={});(Je[f].vx!=N||Je[f].vy!=B||Je[f].el!==h)&&(Je[f].el=h,Je[f].vx=N,Je[f].vy=B,clearInterval(Je[f].pid),(N!=0||B!=0)&&(u=!0,Je[f].pid=setInterval(function(){n&&this.layer===0&&ve.active._onTouchMove(pn);var Z=Je[this.layer].vy?Je[this.layer].vy*a:0,W=Je[this.layer].vx?Je[this.layer].vx*a:0;typeof c=="function"&&c.call(ve.dragged.parentNode[vt],W,Z,r,pn,Je[this.layer].el)!=="continue"||Ds(Je[this.layer].el,W,Z)}.bind({layer:f}),24))),f++}while(e.bubbleScroll&&d!==l&&(d=Kt(d,!1)));ai=u}},30),_s=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,i=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(!!t){var u=n||s;a();var c=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,f=document.elementFromPoint(c.clientX,c.clientY);l(),u&&!u.el.contains(f)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function ui(){}ui.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=fr(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(t,o):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:_s};jt(ui,{pluginName:"revertOnSpill"});function ci(){}ci.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,o=n||this.sortable;o.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),o.animateAll()},drop:_s};jt(ci,{pluginName:"removeOnSpill"});ve.mount(new bf);ve.mount(ci,ui);var hr=ve;var Ns={name:function(r,e){let t=r.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created:function(r,e){let t=Number(r.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated:function(r,e){let t=Number(r.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},di=class{constructor(e){this.elem=e,this.sortContainer=e.querySelector("[book-sort-boxes]"),this.input=e.querySelector("[book-sort-input]");let t=e.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),window.$events.listen("entity-select-confirm",this.bookSelect.bind(this))}setupSortPresets(){let e="",t=!1,n=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let i=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");t=e===a?!t:!1;let l=Ns[a];t&&n.includes(a)&&(l=function(u,c){return 0-Ns[a](u,c)});for(let u of i)Array.from(u.children).filter(f=>f.matches("li")).sort(l).forEach(f=>{u.appendChild(f)});e=a,this.updateMapInput()})}bookSelect(e){if(this.elem.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=document.createElement("div");s.innerHTML=o.data;let i=s.children[0];this.sortContainer.append(i),this.setupBookSortable(i)})}setupBookSortable(e){let t=[e.querySelector(".sort-list")];t.push(...e.querySelectorAll(".entity-list-item + ul"));let n={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put:function(s,i,a){return a.getAttribute("data-type")==="page"}};for(let s of t)new hr(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:this.updateMapInput.bind(this),dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"CTRL",selectedClass:"sortable-selected"})}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.elem.querySelectorAll(".sort-list");for(let n of t){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(i=>i.matches('[data-type="page"], [data-type="chapter"]'));for(let i=0;i<s.length;i++)this.addBookChildToMap(s[i],i,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),i=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:i,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let u=0;u<l.length;u++)o.push({id:l[u].getAttribute("data-id"),sort:u,parentChapter:a,type:"page",book:n})}},Bs=di;var gn=new WeakMap;function $s(r,e=400,t=null){Br(r),r.style.display="block",Nr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function vn(r,e=400,t=null){Br(r),Nr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function pr(r,e=400){Br(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[o,"0px"],paddingBottom:[s,"0px"]};Nr(r,i,e,()=>{r.style.display="none"})}function mr(r,e=400){Br(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",o],paddingBottom:["0px",s]};Nr(r,i,e)}function Us(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{Br(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),u=a.getPropertyValue("padding-bottom"),c={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,u]};Nr(r,c,e)}}function Nr(r,e,t=400,n=null){let o=Object.keys(e);for(let i of o)r.style[i]=e[i][0];let s=()=>{for(let i of o)r.style[i]=null;r.style.transition=null,r.removeEventListener("transitionend",s),gn.delete(r),n&&n()};setTimeout(()=>{r.style.transition=`all ease-in-out ${t}ms`;for(let i of o)r.style[i]=e[i][1];r.addEventListener("transitionend",s),gn.set(r,s)},15)}function Br(r){gn.has(r)&&gn.get(r)()}var fi=class{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),mr(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),pr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}},zs=fi;var hi=class{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.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()}),Be(this.languageLinks,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),Jr(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Be(this.saveButton,e=>this.save()),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.languageInputChange(t)).then(()=>window.importVersioned("code")).then(o=>o.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.popup.components.popup.show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.popup.components.popup.hide(),this.addHistory()}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase(),n=!1;for(let o of this.languageLinks){let s=o.dataset.lang.toLowerCase().trim(),i=t&&s.startsWith(t);o.classList.toggle("active",i),i&&!n&&(o.scrollIntoView({block:"center",behavior:"smooth"}),n=!0)}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}},js=hi;var pi=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},Hs=pi;var mi=class{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}},qs=mi;var gi=class{constructor(e){this.elem=e,this.trigger=e.querySelector("[collapsible-trigger]"),this.content=e.querySelector("[collapsible-content]"),this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.elem.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),mr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),pr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},Vs=gi;var vi=class{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Be(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return this.container.components.popup}sendResult(e){this.res&&(this.res(e),this.res=null)}},Gs=vi;var yi=class{constructor(e){this.elem=e,this.checkbox=e.querySelector("input[type=checkbox]"),this.display=e.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.elem.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}},Ws=yi;var bi=class{constructor(e){this.elem=e,this.dealtWith=!1,e.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.elem.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.elem)}),this.dealtWith=!0)}},Ys=bi;var xi=class{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.setupListeners(),this.hide=this.hide.bind(this)}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,s=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.direction==="right"?this.menu.style.right=`${t.right-t.width}px`:this.menu.style.left=`${t.left}px`,this.menu.style.width=`${t.width}px`,n=s?window.innerHeight-t.top-o/2:t.top),s?(this.menu.style.top="initial",this.menu.style.bottom=`${n}px`):(this.menu.style.top=`${n}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide.bind(this)),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let i=this.menu.querySelector("input");i!==null&&i.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.components.dropdown)e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.container.appendChild(this.menu)),this.showing=!1}getFocusable(){return Array.from(this.menu.querySelectorAll('[tabindex]:not([tabindex="-1"]),[href],button,input:not([type=hidden])'))}focusNext(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}setupListeners(){this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Be(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&this.focusNext()});let e=t=>{t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"&&(this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation())};this.container.addEventListener("keydown",e),this.moveMenu&&this.menu.addEventListener("keydown",e),this.menu.addEventListener("keydown ",t=>{t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.hide())})}},Ks=xi;var wi=class{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Ar(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let n of t){let o=!e||n.textContent.toLowerCase().includes(e);n.style.display=o?"flex":"none",n.classList.toggle("hidden",!o)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=Us(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}},Xs=wi;var Qs=Yr(Zs());var Si=class{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new Qs.default(this.container,{addRemoveLinks:!0,dictRemoveFile:this.removeMessage,timeout:Number(window.uploadTimeout)||6e4,maxFilesize:this.uploadLimit,url:this.url,withCredentials:!0,init(){this.dz=this,this.dz.on("sending",e.onSending.bind(e)),this.dz.on("success",e.onSuccess.bind(e)),this.dz.on("error",e.onError.bind(e))}})}onSending(e,t,n){let o=window.document.querySelector("meta[name=token]").getAttribute("content");n.append("_token",o),t.ontimeout=s=>{this.dz.emit("complete",e),this.dz.emit("error",e,this.timeoutMessage)}}onSuccess(e,t){this.$emit("success",{file:e,data:t}),this.successMessage&&window.$events.emit("success",this.successMessage),vn(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let o=s=>{let i=e.previewElement.querySelector("[data-dz-errormessage]");i.textContent=s};n&&n.status===413?o(this.uploadLimitMessage):t.file&&o(t.file)}removeAll(){this.dz.removeAllFiles(!0)}},Js=Si;var Ci=class{constructor(e){this.elem=e,this.buttons=e.querySelectorAll("[toolbox-tab-button]"),this.contentElements=e.querySelectorAll("[toolbox-tab-content]"),this.toggleButton=e.querySelector("[toolbox-toggle]"),this.toggleButton.addEventListener("click",this.toggle.bind(this)),this.elem.addEventListener("click",t=>{let n=t.target.closest("[toolbox-tab-button]");if(n===null)return;let o=n.getAttribute("toolbox-tab-button");this.setActiveTab(o,!0)}),this.setActiveTab(this.contentElements[0].getAttribute("toolbox-tab-content"))}toggle(){this.elem.classList.toggle("open");let e=this.elem.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n=0,o=this.buttons.length;n<o;n++)this.buttons[n].classList.remove("active"),this.buttons[n].getAttribute("toolbox-tab-button")===e&&this.buttons[n].classList.add("active");for(let n=0,o=this.contentElements.length;n<o;n++)this.contentElements[n].style.display="none",this.contentElements[n].getAttribute("toolbox-tab-content")===e&&(this.contentElements[n].style.display="block");t&&!this.elem.classList.contains("open")&&this.toggle()}},ea=Ci;var Ai=class{constructor(e){this.permissionsTable=e.querySelector("[permissions-table]"),this.restrictedCheckbox=e.querySelector("[name=restricted]"),this.restrictedCheckbox.addEventListener("change",this.updateTableVisibility.bind(this))}updateTableVisibility(){this.permissionsTable.style.display=this.restrictedCheckbox.checked?null:"none"}},ta=Ai;var ki=class{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),Be(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}},ra=ki;var Ti=class{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.addButton=this.$refs.add,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",t=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),this.addButton&&this.addButton.addEventListener("click",t=>{this.selectedItemData&&(this.confirmSelection(this.selectedItemData),this.unselectAll())}),We(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/ajax/search/entities?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(n=>{this.resultsContainer.innerHTML=n.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),n=e.getAttribute("data-entity-type"),o=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${o}`:"";let i=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:i};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}},na=Ti;var Ii=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,window.EntitySelectorPopup=this,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.onSelectionConfirm.bind(this))}show(e){this.callback=e,this.elem.components.popup.show(),this.getSelector().focusSearch()}hide(){this.elem.components.popup.hide()}getSelector(){return this.selectorEl.components["entity-selector"]}onSelectButtonClick(){this.hide(),this.selection!==null&&this.callback&&this.callback(this.selection)}onSelectionConfirm(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}},ia=Ii;var Di=class{setup(){this.container=this.$el,this.name=this.$opts.name,Be(this.$el,()=>{this.$emit(this.name,this.$opts)})}},oa=Di;var Li=class{constructor(e){this.elem=e,this.isOpen=e.getAttribute("expand-toggle-is-open")==="yes",this.updateEndpoint=e.getAttribute("expand-toggle-update-endpoint"),this.selector=e.getAttribute("expand-toggle"),e.addEventListener("click",this.click.bind(this))}open(e){mr(e,200)}close(e){pr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.selector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}},sa=Li;var Fi=class{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}},aa=Fi;var Ri=class{constructor(e){this.elem=e,this.typeControl=e.querySelector('[name="setting-app-homepage-type"]'),this.pagePickerContainer=e.querySelector("[page-picker-container]"),this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}},la=Ri;var Oi=class{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.formContainer=this.$refs.formContainer,this.dropzoneContainer=this.$refs.dropzoneContainer,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners(),window.ImageManager=this}setupListeners(){Be(this.filterTabs,e=>{this.resetAll(),this.filter=e.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",e=>{this.resetListView(),this.loadGallery(),e.preventDefault()}),Be(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),We(this.listContainer,".load-more","click",async e=>{Cr(e.target),this.page++,await this.loadGallery(),e.target.remove()}),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",e=>{e.target.src=baseUrl("loading_error.png")},!0),Be(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),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),is(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e,window.components.init(t);for(let n of[...t.children])this.listContainer.appendChild(n)}setActiveFilterTab(e){this.filterTabs.forEach(n=>n.classList.remove("selected"));let t=this.filterTabs.find(n=>n.dataset.filter===e);t&&t.classList.add("selected")}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value=""}resetEditForm(){this.formContainer.innerHTML=""}resetListView(){Cr(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),o?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,window.components.init(this.formContainer)}},ua=Oi;var Pi=class{constructor(e){this.elem=e,this.imageElem=e.querySelector("img"),this.imageInput=e.querySelector("input[type=file]"),this.resetInput=e.querySelector("input[data-reset-input]"),this.removeInput=e.querySelector("input[data-remove-input]"),this.defaultImage=e.getAttribute("data-default-image"),e.querySelector('button[data-action="reset-image"]').addEventListener("click",this.reset.bind(this));let n=e.querySelector('button[data-action="remove-image"]');n&&n.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}},ca=Pi;var Mi=class{constructor(e){this.elem=e,this.menu=e.querySelector("ul"),this.sortInput=e.querySelector('[name="sort"]'),this.orderInput=e.querySelector('[name="order"]'),this.form=e.querySelector("form"),this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let n=this.orderInput.value==="asc"?"desc":"asc";this.orderInput.value=n,e.preventDefault(),this.form.submit()}},da=Mi;var Dc=Yr(vc()),Lc=Yr(Ec());var ho=class{constructor(e){this.data=e}hasItems(){return Boolean(this.data)&&Boolean(this.data.types)&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let e=this.data.types,t=this.data.files,n=[];for(let o of e)if(o.includes("image")){let s=this.data.getData(o);n.push(s.getAsFile())}for(let o of t)o.type.includes("image")&&n.push(o);return n}},Hr=ho;function jp(r,e){return document.createElement(r,e)}function Hp(r,e,t){return document.createElementNS(r,e,t)}function qp(){return document.createDocumentFragment()}function Vp(r){return document.createTextNode(r)}function Gp(r){return document.createComment(r)}function Wp(r,e,t){r.insertBefore(e,t)}function Yp(r,e){r.removeChild(e)}function Kp(r,e){r.appendChild(e)}function Xp(r){return r.parentNode}function Zp(r){return r.nextSibling}function Qp(r){return r.tagName}function Jp(r,e){r.textContent=e}function em(r){return r.textContent}function tm(r){return r.nodeType===1}function rm(r){return r.nodeType===3}function nm(r){return r.nodeType===8}function im(r){return r.nodeType===11}var On={createElement:jp,createElementNS:Hp,createTextNode:Vp,createDocumentFragment:qp,createComment:Gp,insertBefore:Wp,removeChild:Yp,appendChild:Kp,parentNode:Xp,nextSibling:Zp,tagName:Qp,setTextContent:Jp,getTextContent:em,isElement:tm,isText:rm,isComment:nm,isDocumentFragment:im};function qt(r,e,t,n,o){let s=e===void 0?void 0:e.key;return{sel:r,data:e,children:t,text:n,elm:o,key:s}}var Sc=Array.isArray;function Cc(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function po(r){return r===void 0}function pt(r){return r!==void 0}var mo=qt("",{},[],void 0,void 0);function qr(r,e){var t,n;let o=r.key===e.key,s=((t=r.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is);return r.sel===e.sel&&o&&s}function sm(){throw new Error("The document fragment is not supported on this platform.")}function am(r,e){return r.isElement(e)}function lm(r,e){return r.isDocumentFragment(e)}function um(r,e,t){var n;let o={};for(let s=e;s<=t;++s){let i=(n=r[s])===null||n===void 0?void 0:n.key;i!==void 0&&(o[i]=s)}return o}var cm=["create","update","remove","destroy","pre","post"];function go(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:On;for(let p of cm)for(let g of r){let y=g[p];y!==void 0&&n[p].push(y)}function s(p){let g=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return qt(o.tagName(p).toLowerCase()+g+b,{},[],void 0,p)}function i(p){return qt(void 0,{},[],void 0,p)}function a(p,g){return function(){if(--g===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,g){var y,b,x,k;let S,O=p.data;if(O!==void 0){let A=(y=O.hook)===null||y===void 0?void 0:y.init;pt(A)&&(A(p),O=p.data)}let C=p.children,P=p.sel;if(P==="!")po(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(P!==void 0){let A=P.indexOf("#"),D=P.indexOf(".",A),I=A>0?A:P.length,M=D>0?D:P.length,N=A!==-1||D!==-1?P.slice(0,Math.min(I,M)):P,B=p.elm=pt(O)&&pt(S=O.ns)?o.createElementNS(S,N,O):o.createElement(N,O);for(I<M&&B.setAttribute("id",P.slice(I+1,M)),D>0&&B.setAttribute("class",P.slice(M+1).replace(/\./g," ")),S=0;S<n.create.length;++S)n.create[S](mo,p);if(Sc(C))for(S=0;S<C.length;++S){let Z=C[S];Z!=null&&o.appendChild(B,l(Z,g))}else Cc(p.text)&&o.appendChild(B,o.createTextNode(p.text));let H=p.data.hook;pt(H)&&((b=H.create)===null||b===void 0||b.call(H,mo,p),H.insert&&g.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let A=p.children;for(p.elm=((k=o.createDocumentFragment)!==null&&k!==void 0?k:sm)(),S=0;S<n.create.length;++S)n.create[S](mo,p);for(S=0;S<A.length;++S){let D=A[S];D!=null&&o.appendChild(p.elm,l(D,g))}}else p.elm=o.createTextNode(p.text);return p.elm}function u(p,g,y,b,x,k){for(;b<=x;++b){let S=y[b];S!=null&&o.insertBefore(p,l(S,k),g)}}function c(p){var g,y;let b=p.data;if(b!==void 0){(y=(g=b?.hook)===null||g===void 0?void 0:g.destroy)===null||y===void 0||y.call(g,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let k=p.children[x];k!=null&&typeof k!="string"&&c(k)}}}function f(p,g,y,b){for(var x,k;y<=b;++y){let S,O,C=g[y];if(C!=null)if(pt(C.sel)){c(C),S=n.remove.length+1,O=a(C.elm,S);for(let A=0;A<n.remove.length;++A)n.remove[A](C,O);let P=(k=(x=C?.data)===null||x===void 0?void 0:x.hook)===null||k===void 0?void 0:k.remove;pt(P)?P(C,O):O()}else o.removeChild(p,C.elm)}}function d(p,g,y,b){let x=0,k=0,S=g.length-1,O=g[0],C=g[S],P=y.length-1,A=y[0],D=y[P],I,M,N,B;for(;x<=S&&k<=P;)O==null?O=g[++x]:C==null?C=g[--S]:A==null?A=y[++k]:D==null?D=y[--P]:qr(O,A)?(h(O,A,b),O=g[++x],A=y[++k]):qr(C,D)?(h(C,D,b),C=g[--S],D=y[--P]):qr(O,D)?(h(O,D,b),o.insertBefore(p,O.elm,o.nextSibling(C.elm)),O=g[++x],D=y[--P]):qr(C,A)?(h(C,A,b),o.insertBefore(p,C.elm,O.elm),C=g[--S],A=y[++k]):(I===void 0&&(I=um(g,x,S)),M=I[A.key],po(M)?o.insertBefore(p,l(A,b),O.elm):(N=g[M],N.sel!==A.sel?o.insertBefore(p,l(A,b),O.elm):(h(N,A,b),g[M]=void 0,o.insertBefore(p,N.elm,O.elm))),A=y[++k]);k<=P&&(B=y[P+1]==null?null:y[P+1].elm,u(p,B,y,k,P,b)),x<=S&&f(p,g,x,S)}function h(p,g,y){var b,x,k,S,O,C,P,A;let D=(b=g.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,g);let I=g.elm=p.elm,M=p.children,N=g.children;if(p!==g){if(g.data!==void 0||pt(g.text)&&g.text!==p.text){(k=g.data)!==null&&k!==void 0||(g.data={}),(S=p.data)!==null&&S!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,g);(P=(C=(O=g.data)===null||O===void 0?void 0:O.hook)===null||C===void 0?void 0:C.update)===null||P===void 0||P.call(C,p,g)}po(g.text)?pt(M)&&pt(N)?M!==N&&d(I,M,N,y):pt(N)?(pt(p.text)&&o.setTextContent(I,""),u(I,null,N,0,N.length-1,y)):pt(M)?f(I,M,0,M.length-1):pt(p.text)&&o.setTextContent(I,""):p.text!==g.text&&(pt(M)&&f(I,M,0,M.length-1),o.setTextContent(I,g.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,g)}}return function(g,y){let b,x,k,S=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(am(o,g)?g=s(g):lm(o,g)&&(g=i(g)),qr(g,y)?h(g,y,S):(x=g.elm,k=o.parentNode(x),l(y,S),k!==null&&(o.insertBefore(k,y.elm,o.nextSibling(x)),f(k,[g],0,0))),b=0;b<S.length;++b)S[b].data.hook.insert(S[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function vo(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&vo(s,o.children,o.sel)}}function Vr(r,e){let t=e!==void 0?e:On,n;if(t.isElement(r)){let o=r.id?"#"+r.id:"",s=r.getAttribute("class"),i=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+o+i,l={},u={},c={},f=[],d,h,p,g=r.attributes,y=r.childNodes;for(h=0,p=g.length;h<p;h++)d=g[h].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?u[d.slice(5)]=g[h].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=g[h].nodeValue);for(h=0,p=y.length;h<p;h++)f.push(Vr(y[h],e));return Object.keys(l).length>0&&(c.attrs=l),Object.keys(u).length>0&&(c.datasets=u),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&vo(c,f,a),qt(a,c,f,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),qt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),qt("!",{},[],n,r)):qt("",{},[],void 0,r)}var dm="http://www.w3.org/1999/xlink",fm="http://www.w3.org/XML/1998/namespace";function Ac(r,e){let t,n=e.elm,o=r.data.attrs,s=e.data.attrs;if(!(!o&&!s)&&o!==s){o=o||{},s=s||{};for(t in s){let i=s[t];o[t]!==i&&(i===!0?n.setAttribute(t,""):i===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,i):t.charCodeAt(3)===58?n.setAttributeNS(fm,t,i):t.charCodeAt(5)===58?n.setAttributeNS(dm,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var yo={create:Ac,update:Ac};var Pn;function hm(){return Pn||(Pn=go([yo]),Pn)}function kc(r,e){let t=document.createElement("div");t.innerHTML=e,hm()(Vr(r),Vr(t))}var _t=null,wo,bo,xo;function pm(r,e,t){bo=e,xo=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tc),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),wo=new URL(r).origin}function mm(){Ic()}function Tc(r){if(!r.data||r.data.length<1||r.origin!==wo)return;let e=JSON.parse(r.data);e.event==="init"?ym():e.event==="exit"?Ic():e.event==="save"?vm(e):e.event==="export"?gm(e):e.event==="configure"&&bm()}function gm(r){xo&&xo(r.data)}function vm(r){Eo({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function ym(){!bo||bo().then(r=>{Eo({action:"load",autosave:1,xml:r})})}function bm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),Eo({action:"configure",config:r})}function Ic(){window.removeEventListener("message",Tc),_t&&document.body.removeChild(_t)}function Eo(r){_t.contentWindow.postMessage(JSON.stringify(r),wo)}async function xm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function wm(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var bt={show:pm,close:mm,upload:xm,load:wm};var So=class{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.markdown=new Dc.default({html:!0}),this.markdown.use(Lc.default,{label:!0}),this.display=this.elem.querySelector(".markdown-display"),this.displayStylesLoaded=!1,this.input=this.elem.querySelector("textarea"),this.cm=null,this.Code=null;let e=window.importVersioned("code").then(n=>(this.cm=n.markdownEditor(this.input),this.Code=n,this.cm));this.onMarkdownScroll=this.onMarkdownScroll.bind(this);let t=()=>{this.displayDoc=this.display.contentDocument,this.init(e)};this.display.contentDocument.readyState==="complete"?t():this.display.addEventListener("load",t.bind(this)),window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.markdown,displayEl:this.display,codeMirrorInstance:this.cm})}init(e){let t=0;this.displayDoc.addEventListener("click",s=>{let i=Date.now()-t<300,a=s.target.closest("a");if(a!==null){s.preventDefault(),window.open(a.getAttribute("href"));return}let l=s.target.closest("[drawio-diagram]");if(l!==null&&i){this.actionEditDrawing(l);return}t=Date.now()}),this.elem.addEventListener("click",s=>{let i=s.target.closest("button[data-action]");if(i===null)return;let a=i.getAttribute("data-action");if(a==="insertImage"&&this.actionInsertImage(),a==="insertLink"&&this.actionShowLinkSelector(),a==="insertDrawing"&&(s.ctrlKey||s.metaKey)){this.actionShowImageManager();return}a==="insertDrawing"&&this.actionStartDrawing(),a==="fullscreen"&&this.actionFullScreen()}),this.elem.addEventListener("click",s=>{let i=s.target.closest(".editor-toolbar-label");if(!i)return;let a=this.elem.querySelectorAll(".markdown-editor-wrap");for(let l of a)l.classList.remove("active");i.closest(".markdown-editor-wrap").classList.add("active")}),e.then(s=>{this.codeMirrorSetup(s);let i=Ar(()=>this.Code.updateLayout(s),100,!1);new ResizeObserver(i).observe(this.elem)}),this.listenForBookStackEditorEvents();let o=new URL(window.location).searchParams.get("content-text");o&&this.scrollToText(o)}updateAndRender(){let e=this.cm.getValue();this.input.value=e;let t=this.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e);let n=this.getDisplayTarget();this.displayDoc.body.className="page-content",kc(n,t),this.loadStylesIntoDisplay()}getDisplayTarget(){let e=this.displayDoc.body;if(e.children.length===0){let t=document.createElement("div");this.displayDoc.body.append(t)}return e.children[0]}loadStylesIntoDisplay(){if(this.displayStylesLoaded)return;this.displayDoc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.displayDoc.documentElement.style.backgroundColor="#222",this.displayDoc.documentElement.classList.add("dark-mode")),this.displayDoc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.displayDoc.head.appendChild(n)}this.displayStylesLoaded=!0}onMarkdownScroll(e){let t=this.displayDoc.body.children;if(t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}codeMirrorSetup(e){let t=this;e.setOption("direction","ltr");let n=this.Code.getMetaKey(),o={};o[`${n}-Alt-I`]=function(d){let p=``,g=d.getCursor("from");d.replaceSelection(p),d.setCursor(g.line,g.ch+p.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('<p class="callout info">',"</p>")},e.setOption("extraKeys",o),e.on("change",(d,h)=>{this.updateAndRender()});let s=Ar(d=>{let h=d.getScrollInfo();if(h.top+h.clientHeight===h.height){this.onMarkdownScroll(-1);return}let g=d.lineAtHeight(h.top,"local"),y=d.getRange({line:0,ch:null},{line:g,ch:null}),k=new DOMParser().parseFromString(this.markdown.render(y),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(k.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,h)=>{let p=new Hr(h.clipboardData||h.dataTransfer);if(!p.hasItems()||p.containsTabularData())return;let g=p.getImages();for(let y of g)c(y)}),e.on("drop",(d,h)=>{let p=h.dataTransfer.getData("bookstack/template");if(p){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.preventDefault(),window.$http.get(`/templates/${p}`).then(b=>{let x=b.data.markdown||b.data.html;d.replaceSelection(x)})}let g=new Hr(h.dataTransfer);if(g.hasItems()&&g.getImages().length>0){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.stopPropagation(),h.preventDefault();let b=g.getImages();for(let x of b)c(x)}});function i(d,h){let p=e.getValue(),g=e.listSelections();e.setValue(p.replace(d,h)),e.setSelections(g)}function a(d){let h=e.getCursor(),p=e.getLine(h.line),g=p.length,y=p.split(" ")[0];if(y===d){p=p.replace(`${d} `,""),e.replaceRange(p,{line:h.line,ch:0},{line:h.line,ch:g}),e.setCursor({line:h.line,ch:h.ch-(d.length+1)});return}let b=/^[#>`]/.test(y),x=0;b?(x=d.length-y.length,p=p.replace(y,d).trim()):d!==""&&(x=d.length+1,p=d+" "+p),e.replaceRange(p,{line:h.line,ch:0},{line:h.line,ch:g}),e.setCursor({line:h.line,ch:h.ch+x})}function l(d,h){let p=e.getCursor(),g=e.getLine(p.line),y=g.length,b=g;g.indexOf(d)===0&&g.slice(-h.length)===h?b=g.slice(d.length,g.length-h.length):b=`${d}${g}${h}`,e.replaceRange(b,{line:p.line,ch:0},{line:p.line,ch:y}),e.setCursor({line:p.line,ch:p.ch+d.length})}function u(d,h){let p=e.getSelection();if(p==="")return l(d,h);let g=p,y=0,b=0;p.indexOf(d)===0&&p.slice(-h.length)===h?(g=p.slice(d.length,p.length-h.length),b=-(h.length+d.length)):(g=`${d}${p}${h}`,b=d.length+h.length);let x=e.listSelections()[0];e.replaceSelection(g);let k=x.head.ch<=x.anchor.ch;x.head.ch+=k?y:b,x.anchor.ch+=k?b:y,e.setSelections([x])}function c(d){if(d===null||d.type.indexOf("image")!==0)return;let h="png";if(d.name){let O=d.name.match(/\.(.+)$/);O.length>1&&(h=O[1])}let p="image-"+Math.random().toString(16).slice(2),g=window.baseUrl(`/loading.gif#upload${p}`),y=e.getSelection(),b=``,x=e.getCursor();e.replaceSelection(b),e.setCursor({line:x.line,ch:x.ch+y.length+3});let k="image-"+Date.now()+"."+h,S=new FormData;S.append("file",d,k),S.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",S).then(O=>{let C=`[](${O.data.url})`;i(b,C)}).catch(O=>{window.$events.emit("error",t.imageUploadErrorText),i(b,y),console.log(O)})}function f(){let d=e.getCursor("from"),h=e.getSelection()||"",p=`[${h}]()`;e.focus(),e.replaceSelection(p);let g=h===""?-3:-1;e.setCursor(d.line,d.ch+p.length+g)}this.updateAndRender()}actionInsertImage(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{let n=t.thumbs.display||t.url,o=this.cm.getSelection(),s="[]("+t.url+")";this.cm.focus(),this.cm.replaceSelection(s),this.cm.setCursor(e.line,e.ch+s.length)},"gallery")}actionShowImageManager(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{this.insertDrawing(t,e)},"drawio")}actionShowLinkSelector(){let e=this.cm.getCursor("from");window.EntitySelectorPopup.show(t=>{let o=`[${this.cm.getSelection()||t.name}](${t.link})`;this.cm.focus(),this.cm.replaceSelection(o),this.cm.setCursor(e.line,e.ch+o.length)})}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):!1}actionStartDrawing(){let e=this.getDrawioUrl();if(!e)return;let t=this.cm.getCursor("from");bt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),bt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.cm.focus(),this.cm.replaceSelection(n),this.cm.setCursor(t.line,t.ch+n.length)}actionEditDrawing(e){let t=this.getDrawioUrl();if(!t)return;let n=this.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");bt.show(t,()=>bt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,u=this.cm.getValue().split(`
+`);Kr("error",e)}}var Jo={emit:Kr,emitPublic:$d,listen:Bd,success:r=>Kr("success",r),error:r=>Kr("error",r),showValidationErrors:Ud};async function zd(r,e={}){return es(r,{method:"GET",params:e})}async function jd(r,e=null){return Xr("POST",r,e)}async function Hd(r,e=null){return Xr("PUT",r,e)}async function qd(r,e=null){return Xr("PATCH",r,e)}async function Vd(r,e=null){return Xr("DELETE",r,e)}async function Xr(r,e,t=null){let n={method:r,body:t};return typeof t=="object"&&!(t instanceof FormData)&&(n.headers={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},n.body=JSON.stringify(t)),t instanceof FormData&&r!=="post"&&(t.append("_method",r),n.method="post"),es(e,n)}async function es(r,e={}){if(r.startsWith("http")||(r=window.baseUrl(r)),e.params){let i=new URL(r);for(let a of Object.keys(e.params)){let l=e.params[a];typeof l<"u"&&l!==null&&i.searchParams.set(a,l)}r=i.toString()}let t=document.querySelector("meta[name=token]").getAttribute("content");e=Object.assign({},e,{credentials:"same-origin"}),e.headers=Object.assign({},e.headers||{},{baseURL:window.baseUrl(""),"X-CSRF-TOKEN":t});let n=await fetch(r,e),s={data:await Gd(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 Gd(r){if(r.status===204)return null;let t=(r.headers.get("Content-Type")||"").split(";")[0].split("/").pop();return t==="javascript"||t==="json"?await r.json():await r.text()}var ts={get:zd,post:jd,put:Hd,patch:qd,delete:Vd};var Un=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),o=t.getAttribute("value");this.store.set(n,o)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let o=this.getTransText(e);return this.parsePlural(o,t,n)}parsePlural(e,t,n){let o=e.split("|"),s=/^{([0-9]+)}/,i=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let u=l.match(s);if(u!==null&&Number(u[1])===t){a=l.replace(s,"").trim();break}let c=l.match(i);if(c!==null&&Number(c[1])<=t&&(c[2]==="*"||Number(c[2])>=t)){a=l.replace(i,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,n)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let n=e.match(/:([\S]+)/g);return n===null||n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(e=e.replace(o,t[s]))}),e}},rs=Un;function Zr(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function Qr(r,e,t){for(let n of e)r.addEventListener(n,t)}function Be(r,e){Array.isArray(r)||(r=[r]);for(let t of r)t.addEventListener("click",e),t.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),e(n))})}function Jr(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function We(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function ns(r,e){let t=document.querySelectorAll(r);e=e.toLowerCase();for(let n of t)if(n.textContent.toLowerCase().includes(e))return n;return null}function Cr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function is(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Ar(r,e,t){let n;return function(){let o=this,s=arguments,i=function(){n=null,t||r.apply(o,s)},a=t&&!n;clearTimeout(n),n=setTimeout(i,e),a&&r.apply(o,s)}}function kr(r){if(!r)return;r.scrollIntoView({behavior:"smooth"});let e=document.getElementById("custom-styles").getAttribute("data-color-light"),t=window.getComputedStyle(r).getPropertyValue("background-color");r.style.backgroundColor=e,setTimeout(()=>{r.classList.add("selectFade"),r.style.backgroundColor=t},10),setTimeout(()=>{r.classList.remove("selectFade"),r.style.backgroundColor=""},3e3)}function ss(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function as(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var zn=class{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),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=as(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}},ls=zn;var jn=class{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Be(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}},us=jn;var Hn=class{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}Jr(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Be(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}},cs=Hn;var qn=class{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})})}reloadList(){this.stopEdit(),this.mainTabs.components.tabs.show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(e=>{this.list.innerHTML=e.data,window.components.init(this.list)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),Cr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}},ds=qn;var Vn=class{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href=t.href+"?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}},fs=Vn;var Gn={},Wn=class{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()}),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.container.addEventListener("keydown",this.containerKeyDown.bind(this)),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(Gn[o])return Gn[o];let s=await window.$http.get(this.url,n);return Gn[o]=s.data,s.data}displaySuggestions(e){if(e.length===0)return this.hideSuggestions();this.list.innerHTML=e.map(t=>`<li><button type="button" class="text-item">${ss(t)}</button></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll("button"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}},hs=Wn;var Yn=class{constructor(e){if(this.elem=e,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.elem.style.display="none";return}this.elem.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.elem.style.display="block",this.showing=!0,setTimeout(()=>{this.elem.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.elem.style.opacity=0,this.showing=!1,setTimeout(()=>{this.elem.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,n=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function i(){let a=1-(Date.now()-o)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(i.bind(this))):t.scrollTop=e}requestAnimationFrame(i.bind(this))}},ps=Yn;function ms(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(r,o).enumerable})),t.push.apply(t,n)}return t}function Rt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ms(Object(t),!0).forEach(function(n){Wd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ms(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function on(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?on=function(e){return typeof e}:on=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},on(r)}function Wd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function jt(){return jt=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},jt.apply(this,arguments)}function Yd(r,e){if(r==null)return{};var t={},n=Object.keys(r),o,s;for(s=0;s<n.length;s++)o=n[s],!(e.indexOf(o)>=0)&&(t[o]=r[o]);return t}function Kd(r,e){if(r==null)return{};var t=Yd(r,e),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(o=0;o<s.length;o++)n=s[o],!(e.indexOf(n)>=0)&&(!Object.prototype.propertyIsEnumerable.call(r,n)||(t[n]=r[n]))}return t}var Xd="1.15.0";function zt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Ht=zt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Mr=zt(/Edge/i),gs=zt(/firefox/i),Lr=zt(/safari/i)&&!zt(/chrome/i)&&!zt(/android/i),Cs=zt(/iP(ad|od|hone)/i),As=zt(/chrome/i)&&zt(/android/i),ks={capture:!1,passive:!1};function Me(r,e,t){r.addEventListener(e,t,!Ht&&ks)}function Le(r,e,t){r.removeEventListener(e,t,!Ht&&ks)}function cn(r,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),r)try{if(r.matches)return r.matches(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e)}catch{return!1}return!1}}function Zd(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Lt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&cn(r,e):cn(r,e))||n&&r===t)return r;if(r===t)break}while(r=Zd(r))}return null}var vs=/\s+/g;function mt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(vs," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(vs," ")}}function ge(r,e,t){var n=r&&r.style;if(n){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(r,""):r.currentStyle&&(t=r.currentStyle),e===void 0?t:t[e];!(e in n)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),n[e]=t+(typeof t=="string"?"":"px")}}function dr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ge(r,"transform");n&&n!=="none"&&(t=n+" "+t)}while(!e&&(r=r.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(t)}function Ts(r,e,t){if(r){var n=r.getElementsByTagName(e),o=0,s=n.length;if(t)for(;o<s;o++)t(n[o],o);return n}return[]}function Ft(){var r=document.scrollingElement;return r||document.documentElement}function tt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,u,c,f;if(r!==window&&r.parentNode&&r!==Ft()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,u=s.right,c=s.height,f=s.width):(i=0,a=0,l=window.innerHeight,u=window.innerWidth,c=window.innerHeight,f=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!Ht))do if(o&&o.getBoundingClientRect&&(ge(o,"transform")!=="none"||t&&ge(o,"position")!=="static")){var d=o.getBoundingClientRect();i-=d.top+parseInt(ge(o,"border-top-width")),a-=d.left+parseInt(ge(o,"border-left-width")),l=i+s.height,u=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var h=dr(o||r),p=h&&h.a,g=h&&h.d;h&&(i/=g,a/=p,f/=p,c/=g,l=i+c,u=a+f)}return{top:i,left:a,bottom:l,right:u,width:f,height:c}}}function ys(r,e,t){for(var n=Kt(r,!0),o=tt(r)[e];n;){var s=tt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ft())break;n=Kt(n,!1)}return!1}function fr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ve.ghost&&(n||i[s]!==ve.dragged)&&Lt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function li(r,e){for(var t=r.lastElementChild;t&&(t===ve.ghost||ge(t,"display")==="none"||e&&!cn(t,e));)t=t.previousElementSibling;return t||null}function Et(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ve.clone&&(!e||cn(r,e))&&t++;return t}function bs(r){var e=0,t=0,n=Ft();if(r)do{var o=dr(r),s=o.a,i=o.d;e+=r.scrollLeft*s,t+=r.scrollTop*i}while(r!==n&&(r=r.parentNode));return[e,t]}function Qd(r,e){for(var t in r)if(!!r.hasOwnProperty(t)){for(var n in e)if(e.hasOwnProperty(n)&&e[n]===r[t][n])return Number(t)}return-1}function Kt(r,e){if(!r||!r.getBoundingClientRect)return Ft();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ge(t);if(t.clientWidth<t.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return Ft();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ft()}function Jd(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Kn(r,e){return Math.round(r.top)===Math.round(e.top)&&Math.round(r.left)===Math.round(e.left)&&Math.round(r.height)===Math.round(e.height)&&Math.round(r.width)===Math.round(e.width)}var Fr;function Is(r,e){return function(){if(!Fr){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),Fr=setTimeout(function(){Fr=void 0},e)}}}function ef(){clearTimeout(Fr),Fr=void 0}function Ds(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Ls(r){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(r).cloneNode(!0):t?t(r).clone(!0)[0]:r.cloneNode(!0)}var vt="Sortable"+new Date().getTime();function tf(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ge(o,"display")==="none"||o===ve.ghost)){r.push({target:o,rect:tt(o)});var s=Rt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=dr(o,!0);i&&(s.top-=i.f,s.left-=i.e)}o.fromRect=s}})}},addAnimationState:function(n){r.push(n)},removeAnimationState:function(n){r.splice(Qd(r,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,i=0;r.forEach(function(a){var l=0,u=a.target,c=u.fromRect,f=tt(u),d=u.prevFromRect,h=u.prevToRect,p=a.rect,g=dr(u,!0);g&&(f.top-=g.f,f.left-=g.e),u.toRect=f,u.thisAnimationDuration&&Kn(d,f)&&!Kn(c,f)&&(p.top-f.top)/(p.left-f.left)===(c.top-f.top)/(c.left-f.left)&&(l=nf(p,d,h,o.options)),Kn(f,c)||(u.prevFromRect=c,u.prevToRect=f,l||(l=o.options.animation),o.animate(u,p,f,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(u.animationResetTimer),u.animationResetTimer=setTimeout(function(){u.animationTime=0,u.prevFromRect=null,u.fromRect=null,u.prevToRect=null,u.thisAnimationDuration=null},l),u.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof n=="function"&&n()},i):typeof n=="function"&&n(),r=[]},animate:function(n,o,s,i){if(i){ge(n,"transition",""),ge(n,"transform","");var a=dr(this.el),l=a&&a.a,u=a&&a.d,c=(o.left-s.left)/(l||1),f=(o.top-s.top)/(u||1);n.animatingX=!!c,n.animatingY=!!f,ge(n,"transform","translate3d("+c+"px,"+f+"px,0)"),this.forRepaintDummy=rf(n),ge(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ge(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ge(n,"transition",""),ge(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function rf(r){return r.offsetWidth}function nf(r,e,t,n){return Math.sqrt(Math.pow(e.top-r.top,2)+Math.pow(e.left-r.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*n.animation}var ar=[],Xn={initializeByDefault:!0},_r={mount:function(e){for(var t in Xn)Xn.hasOwnProperty(t)&&!(t in e)&&(e[t]=Xn[t]);ar.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ar.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";ar.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Rt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Rt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){ar.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var u=new a(e,t,e.options);u.sortable=e,u.options=e.options,e[l]=u,jt(n,u.defaults)}});for(var s in e.options)if(!!e.options.hasOwnProperty(s)){var i=this.modifyOption(e,s,e.options[s]);typeof i<"u"&&(e.options[s]=i)}},getEventProperties:function(e,t){var n={};return ar.forEach(function(o){typeof o.eventProperties=="function"&&jt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return ar.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function of(r){var e=r.sortable,t=r.rootEl,n=r.name,o=r.targetEl,s=r.cloneEl,i=r.toEl,a=r.fromEl,l=r.oldIndex,u=r.newIndex,c=r.oldDraggableIndex,f=r.newDraggableIndex,d=r.originalEvent,h=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[vt],!!e){var g,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!Ht&&!Mr?g=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(g=document.createEvent("Event"),g.initEvent(n,!0,!0)),g.to=i||t,g.from=a||t,g.item=o||t,g.clone=s,g.oldIndex=l,g.newIndex=u,g.oldDraggableIndex=c,g.newDraggableIndex=f,g.originalEvent=d,g.pullMode=h?h.lastPutMode:void 0;var x=Rt(Rt({},p),_r.getEventProperties(n,e));for(var k in x)g[k]=x[k];t&&t.dispatchEvent(g),y[b]&&y[b].call(e,g)}}var sf=["evt"],ht=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Kd(n,sf);_r.pluginEvent.bind(ve)(e,t,Rt({dragEl:ee,parentEl:Ze,ghostEl:we,rootEl:qe,nextEl:er,lastDownEl:sn,cloneEl:Ye,cloneHidden:Yt,dragStarted:Tr,putSortable:it,activeSortable:ve.active,originalEvent:o,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt,hideGhostForTarget:Ps,unhideGhostForTarget:Ms,cloneNowHidden:function(){Yt=!0},cloneNowShown:function(){Yt=!1},dispatchSortableEvent:function(a){ct({sortable:t,name:a,originalEvent:o})}},s))};function ct(r){of(Rt({putSortable:it,cloneEl:Ye,targetEl:ee,rootEl:qe,oldIndex:cr,oldDraggableIndex:Rr,newIndex:gt,newDraggableIndex:Wt},r))}var ee,Ze,we,qe,er,sn,Ye,Yt,cr,gt,Rr,Wt,en,it,ur=!1,dn=!1,fn=[],Qt,At,Zn,Qn,xs,ws,Tr,lr,Or,Pr=!1,tn=!1,an,lt,Jn=[],ii=!1,hn=[],mn=typeof document<"u",rn=Cs,Es=Mr||Ht?"cssFloat":"float",af=mn&&!As&&!Cs&&"draggable"in document.createElement("div"),Fs=function(){if(!!mn){if(Ht)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Rs=function(e,t){var n=ge(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=fr(e,0,t),i=fr(e,1,t),a=s&&ge(s),l=i&&ge(i),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+tt(s).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+tt(i).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var f=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===f)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=o&&n[Es]==="none"||i&&n[Es]==="none"&&u+c>o)?"vertical":"horizontal"},lf=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},uf=function(e,t){var n;return fn.some(function(o){var s=o[vt].options.emptyInsertThreshold;if(!(!s||li(o))){var i=tt(o),a=e>=i.left-s&&e<=i.right+s,l=t>=i.top-s&&t<=i.bottom+s;if(a&&l)return n=o}}),n},Os=function(e){function t(s,i){return function(a,l,u,c){var f=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||f))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,u,c),i)(a,l,u,c);var 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||on(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=t(o.pull,!0),n.checkPut=t(o.put),n.revertClone=o.revertClone,e.group=n},Ps=function(){!Fs&&we&&ge(we,"display","none")},Ms=function(){!Fs&&we&&ge(we,"display","")};mn&&!As&&document.addEventListener("click",function(r){if(dn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),dn=!1,!1},!0);var Jt=function(e){if(ee){e=e.touches?e.touches[0]:e;var t=uf(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t,n.preventDefault=void 0,n.stopPropagation=void 0,t[vt]._onDragOver(n)}}},cf=function(e){ee&&ee.parentNode[vt]._isOutsideThisEl(e.target)};function ve(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=jt({},e),r[vt]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(r.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Rs(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(i,a){i.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ve.supportPointer!==!1&&"PointerEvent"in window&&!Lr,emptyInsertThreshold:5};_r.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);Os(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:af,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Me(r,"pointerdown",this._onTapStart):(Me(r,"mousedown",this._onTapStart),Me(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(Me(r,"dragover",this),Me(r,"dragenter",this)),fn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),jt(this,tf())}ve.prototype={constructor:ve,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(lr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,ee):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,u=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=o.filter;if(yf(n),!ee&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Lr&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Lt(l,o.draggable,n,!1),!(l&&l.animated)&&sn!==l)){if(cr=Et(l),Rr=Et(l,o.draggable),typeof c=="function"){if(c.call(this,e,l,this)){ct({sortable:t,rootEl:u,name:"filter",targetEl:l,toEl:n,fromEl:n}),ht("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(c&&(c=c.split(",").some(function(f){if(f=Lt(u,f.trim(),n,!1),f)return ct({sortable:t,rootEl:f,name:"filter",targetEl:l,fromEl:n,toEl:n}),ht("filter",t,{evt:e}),!0}),c)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Lt(u,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,i=o.options,a=s.ownerDocument,l;if(n&&!ee&&n.parentNode===s){var u=tt(n);if(qe=s,ee=n,Ze=ee.parentNode,er=ee.nextSibling,sn=n,en=i.group,ve.dragged=ee,Qt={target:ee,clientX:(t||e).clientX,clientY:(t||e).clientY},xs=Qt.clientX-u.left,ws=Qt.clientY-u.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,ee.style["will-change"]="all",l=function(){if(ht("delayEnded",o,{evt:e}),ve.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!gs&&o.nativeDraggable&&(ee.draggable=!0),o._triggerDragStart(e,t),ct({sortable:o,name:"choose",originalEvent:e}),mt(ee,i.chosenClass,!0)},i.ignore.split(",").forEach(function(c){Ts(ee,c.trim(),ei)}),Me(a,"dragover",Jt),Me(a,"mousemove",Jt),Me(a,"touchmove",Jt),Me(a,"mouseup",o._onDrop),Me(a,"touchend",o._onDrop),Me(a,"touchcancel",o._onDrop),gs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,ee.draggable=!0),ht("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Mr||Ht))){if(ve.eventCanceled){this._onDrop();return}Me(a,"mouseup",o._disableDelayedDrag),Me(a,"touchend",o._disableDelayedDrag),Me(a,"touchcancel",o._disableDelayedDrag),Me(a,"mousemove",o._delayedDragTouchMoveHandler),Me(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&Me(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,i.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ee&&ei(ee),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._disableDelayedDrag),Le(e,"touchend",this._disableDelayedDrag),Le(e,"touchcancel",this._disableDelayedDrag),Le(e,"mousemove",this._delayedDragTouchMoveHandler),Le(e,"touchmove",this._delayedDragTouchMoveHandler),Le(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?Me(document,"pointermove",this._onTouchMove):t?Me(document,"touchmove",this._onTouchMove):Me(document,"mousemove",this._onTouchMove):(Me(ee,"dragend",this),Me(qe,"dragstart",this._onDragStart));try{document.selection?ln(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(ur=!1,qe&&ee){ht("dragStarted",this,{evt:t}),this.nativeDraggable&&Me(document,"dragover",cf);var n=this.options;!e&&mt(ee,n.dragClass,!1),mt(ee,n.ghostClass,!0),ve.active=this,e&&this._appendGhost(),ct({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(At){this._lastX=At.clientX,this._lastY=At.clientY,Ps();for(var e=document.elementFromPoint(At.clientX,At.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(At.clientX,At.clientY),e!==t);)t=e;if(ee.parentNode[vt]._isOutsideThisEl(e),t)do{if(t[vt]){var n=void 0;if(n=t[vt]._onDragOver({clientX:At.clientX,clientY:At.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);Ms()}},_onTouchMove:function(e){if(Qt){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=we&&dr(we,!0),a=we&&i&&i.a,l=we&&i&&i.d,u=rn&<&&bs(lt),c=(s.clientX-Qt.clientX+o.x)/(a||1)+(u?u[0]-Jn[0]:0)/(a||1),f=(s.clientY-Qt.clientY+o.y)/(l||1)+(u?u[1]-Jn[1]:0)/(l||1);if(!ve.active&&!ur){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(we){i?(i.e+=c-(Zn||0),i.f+=f-(Qn||0)):i={a:1,b:0,c:0,d:1,e:c,f};var d="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ge(we,"webkitTransform",d),ge(we,"mozTransform",d),ge(we,"msTransform",d),ge(we,"transform",d),Zn=c,Qn=f,At=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!we){var e=this.options.fallbackOnBody?document.body:qe,t=tt(ee,!0,rn,!0,e),n=this.options;if(rn){for(lt=e;ge(lt,"position")==="static"&&ge(lt,"transform")==="none"&<!==document;)lt=lt.parentNode;lt!==document.body&<!==document.documentElement?(lt===document&&(lt=Ft()),t.top+=lt.scrollTop,t.left+=lt.scrollLeft):lt=Ft(),Jn=bs(lt)}we=ee.cloneNode(!0),mt(we,n.ghostClass,!1),mt(we,n.fallbackClass,!0),mt(we,n.dragClass,!0),ge(we,"transition",""),ge(we,"transform",""),ge(we,"box-sizing","border-box"),ge(we,"margin",0),ge(we,"top",t.top),ge(we,"left",t.left),ge(we,"width",t.width),ge(we,"height",t.height),ge(we,"opacity","0.8"),ge(we,"position",rn?"absolute":"fixed"),ge(we,"zIndex","100000"),ge(we,"pointerEvents","none"),ve.ghost=we,e.appendChild(we),ge(we,"transform-origin",xs/parseInt(we.style.width)*100+"% "+ws/parseInt(we.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(ht("dragStart",this,{evt:e}),ve.eventCanceled){this._onDrop();return}ht("setupClone",this),ve.eventCanceled||(Ye=Ls(ee),Ye.removeAttribute("id"),Ye.draggable=!1,Ye.style["will-change"]="",this._hideClone(),mt(Ye,this.options.chosenClass,!1),ve.clone=Ye),n.cloneId=ln(function(){ht("clone",n),!ve.eventCanceled&&(n.options.removeCloneOnHide||qe.insertBefore(Ye,ee),n._hideClone(),ct({sortable:n,name:"clone"}))}),!t&&mt(ee,s.dragClass,!0),t?(dn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Le(document,"mouseup",n._onDrop),Le(document,"touchend",n._onDrop),Le(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,ee)),Me(document,"drop",n),ge(ee,"transform","translateZ(0)")),ur=!0,n._dragStartId=ln(n._dragStarted.bind(n,t,e)),Me(document,"selectstart",n),Tr=!0,Lr&&ge(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,u=ve.active,c=en===l,f=a.sort,d=it||u,h,p=this,g=!1;if(ii)return;function y(ne,be){ht(ne,p,Rt({evt:e,isOwner:c,axis:h?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:f,fromSortable:d,target:n,completed:x,onMove:function(xe,Fe){return nn(qe,t,ee,o,xe,tt(xe),e,Fe)},changed:k},be))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==d&&d.captureAnimationState()}function x(ne){return y("dragOverCompleted",{insertion:ne}),ne&&(c?u._hideClone():u._showClone(p),p!==d&&(mt(ee,it?it.options.ghostClass:u.options.ghostClass,!1),mt(ee,a.ghostClass,!0)),it!==p&&p!==ve.active?it=p:p===ve.active&&it&&(it=null),d===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==d&&(d.animateAll(),d._ignoreWhileAnimating=null)),(n===ee&&!ee.animated||n===t&&!n.animated)&&(lr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(ee.parentNode[vt]._isOutsideThisEl(e.target),!ne&&Jt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),g=!0}function k(){gt=Et(ee),Wt=Et(ee,a.draggable),ct({sortable:p,name:"change",toEl:t,newIndex:gt,newDraggableIndex:Wt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Lt(n,a.draggable,t,!0),y("dragOver"),ve.eventCanceled)return g;if(ee.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(dn=!1,u&&!a.disabled&&(c?f||(i=Ze!==qe):it===this||(this.lastPutMode=en.checkPull(this,u,ee,e))&&l.checkPut(this,u,ee,e))){if(h=this._getDirection(e,n)==="vertical",o=tt(ee),y("dragOverValid"),ve.eventCanceled)return g;if(i)return Ze=qe,b(),this._hideClone(),y("revert"),ve.eventCanceled||(er?qe.insertBefore(ee,er):qe.appendChild(ee)),x(!0);var S=li(t,a.draggable);if(!S||pf(e,h,this)&&!S.animated){if(S===ee)return x(!1);if(S&&t===e.target&&(n=S),n&&(s=tt(n)),nn(qe,t,ee,o,n,s,e,!!n)!==!1)return b(),S&&S.nextSibling?t.insertBefore(ee,S.nextSibling):t.appendChild(ee),Ze=t,k(),x(!0)}else if(S&&hf(e,h,this)){var O=fr(t,0,a,!0);if(O===ee)return x(!1);if(n=O,s=tt(n),nn(qe,t,ee,o,n,s,e,!1)!==!1)return b(),t.insertBefore(ee,O),Ze=t,k(),x(!0)}else if(n.parentNode===t){s=tt(n);var C=0,P,A=ee.parentNode!==t,D=!lf(ee.animated&&ee.toRect||o,n.animated&&n.toRect||s,h),I=h?"top":"left",M=ys(n,"top","top")||ys(ee,"top","top"),N=M?M.scrollTop:void 0;lr!==n&&(P=s[I],Pr=!1,tn=!D&&a.invertSwap||A),C=mf(e,n,s,h,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,tn,lr===n);var B;if(C!==0){var H=Et(ee);do H-=C,B=Ze.children[H];while(B&&(ge(B,"display")==="none"||B===we))}if(C===0||B===n)return x(!1);lr=n,Or=C;var Z=n.nextElementSibling,W=!1;W=C===1;var te=nn(qe,t,ee,o,n,s,e,W);if(te!==!1)return(te===1||te===-1)&&(W=te===1),ii=!0,setTimeout(ff,30),b(),W&&!Z?t.appendChild(ee):n.parentNode.insertBefore(ee,W?Z:n),M&&Ds(M,0,N-M.scrollTop),Ze=ee.parentNode,P!==void 0&&!tn&&(an=Math.abs(P-tt(n)[I])),k(),x(!0)}if(t.contains(ee))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Le(document,"mousemove",this._onTouchMove),Le(document,"touchmove",this._onTouchMove),Le(document,"pointermove",this._onTouchMove),Le(document,"dragover",Jt),Le(document,"mousemove",Jt),Le(document,"touchmove",Jt)},_offUpEvents:function(){var e=this.el.ownerDocument;Le(e,"mouseup",this._onDrop),Le(e,"touchend",this._onDrop),Le(e,"pointerup",this._onDrop),Le(e,"touchcancel",this._onDrop),Le(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(gt=Et(ee),Wt=Et(ee,n.draggable),ht("drop",this,{evt:e}),Ze=ee&&ee.parentNode,gt=Et(ee),Wt=Et(ee,n.draggable),ve.eventCanceled){this._nulling();return}ur=!1,tn=!1,Pr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),oi(this.cloneId),oi(this._dragStartId),this.nativeDraggable&&(Le(document,"drop",this),Le(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Lr&&ge(document.body,"user-select",""),ge(ee,"transform",""),e&&(Tr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),we&&we.parentNode&&we.parentNode.removeChild(we),(qe===Ze||it&&it.lastPutMode!=="clone")&&Ye&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),ee&&(this.nativeDraggable&&Le(ee,"dragend",this),ei(ee),ee.style["will-change"]="",Tr&&!ur&&mt(ee,it?it.options.ghostClass:this.options.ghostClass,!1),mt(ee,this.options.chosenClass,!1),ct({sortable:this,name:"unchoose",toEl:Ze,newIndex:null,newDraggableIndex:null,originalEvent:e}),qe!==Ze?(gt>=0&&(ct({rootEl:Ze,name:"add",toEl:Ze,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"remove",toEl:Ze,originalEvent:e}),ct({rootEl:Ze,name:"sort",toEl:Ze,fromEl:qe,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),it&&it.save()):gt!==cr&>>=0&&(ct({sortable:this,name:"update",toEl:Ze,originalEvent:e}),ct({sortable:this,name:"sort",toEl:Ze,originalEvent:e})),ve.active&&((gt==null||gt===-1)&&(gt=cr,Wt=Rr),ct({sortable:this,name:"end",toEl:Ze,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ht("nulling",this),qe=ee=Ze=we=er=Ye=sn=Yt=Qt=At=Tr=gt=Wt=cr=Rr=lr=Or=it=en=ve.dragged=ve.ghost=ve.clone=ve.active=null,hn.forEach(function(e){e.checked=!0}),hn.length=Zn=Qn=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":ee&&(this._onDragOver(e),df(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,n=this.el.children,o=0,s=n.length,i=this.options;o<s;o++)t=n[o],Lt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||vf(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Lt(a,this.options.draggable,o,!1)&&(n[s]=a)},this),t&&this.captureAnimationState(),e.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[s]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return Lt(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var n=this.options;if(t===void 0)return n[e];var o=_r.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&Os(n)},destroy:function(){ht("destroy",this);var e=this.el;e[vt]=null,Le(e,"mousedown",this._onTapStart),Le(e,"touchstart",this._onTapStart),Le(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Le(e,"dragover",this),Le(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),fn.splice(fn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Yt){if(ht("hideClone",this),ve.eventCanceled)return;ge(Ye,"display","none"),this.options.removeCloneOnHide&&Ye.parentNode&&Ye.parentNode.removeChild(Ye),Yt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Yt){if(ht("showClone",this),ve.eventCanceled)return;ee.parentNode==qe&&!this.options.group.revertClone?qe.insertBefore(Ye,ee):er?qe.insertBefore(Ye,er):qe.appendChild(Ye),this.options.group.revertClone&&this.animate(ee,Ye),ge(Ye,"display",""),Yt=!1}}};function df(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function nn(r,e,t,n,o,s,i,a){var l,u=r[vt],c=u.options.onMove,f;return window.CustomEvent&&!Ht&&!Mr?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=r,l.dragged=t,l.draggedRect=n,l.related=o||e,l.relatedRect=s||tt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),c&&(f=c.call(u,l,i)),f}function ei(r){r.draggable=!1}function ff(){ii=!1}function hf(r,e,t){var n=tt(fr(t.el,0,t.options,!0)),o=10;return e?r.clientX<n.left-o||r.clientY<n.top&&r.clientX<n.right:r.clientY<n.top-o||r.clientY<n.bottom&&r.clientX<n.left}function pf(r,e,t){var n=tt(li(t.el,t.options.draggable)),o=10;return e?r.clientX>n.right+o||r.clientX<=n.right&&r.clientY>n.bottom&&r.clientX>=n.left:r.clientX>n.right&&r.clientY>n.top||r.clientX<=n.right&&r.clientY>n.bottom+o}function mf(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&&an<u*o){if(!Pr&&(Or===1?l>c+u*s/2:l<f-u*s/2)&&(Pr=!0),Pr)d=!0;else if(Or===1?l<c+an:l>f-an)return-Or}else if(l>c+u*(1-o)/2&&l<f-u*(1-o)/2)return gf(e)}return d=d||i,d&&(l<c+u*s/2||l>f-u*s/2)?l>c+u/2?1:-1:0}function gf(r){return Et(ee)<Et(r)?1:-1}function vf(r){for(var e=r.tagName+r.className+r.src+r.href+r.textContent,t=e.length,n=0;t--;)n+=e.charCodeAt(t);return n.toString(36)}function yf(r){hn.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&hn.push(n)}}function ln(r){return setTimeout(r,0)}function oi(r){return clearTimeout(r)}mn&&Me(document,"touchmove",function(r){(ve.active||ur)&&r.cancelable&&r.preventDefault()});ve.utils={on:Me,off:Le,css:ge,find:Ts,is:function(e,t){return!!Lt(e,t,e,!1)},extend:Jd,throttle:Is,closest:Lt,toggleClass:mt,clone:Ls,index:Et,nextTick:ln,cancelNextTick:oi,detectDirection:Rs,getChild:fr};ve.get=function(r){return r[vt]};ve.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(ve.utils=Rt(Rt({},ve.utils),n.utils)),_r.mount(n)})};ve.create=function(r,e){return new ve(r,e)};ve.version=Xd;var Je=[],Ir,si,ai=!1,ti,ri,pn,Dr;function bf(){function r(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return r.prototype={dragStarted:function(t){var n=t.originalEvent;this.sortable.nativeDraggable?Me(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Me(document,"pointermove",this._handleFallbackAutoScroll):n.touches?Me(document,"touchmove",this._handleFallbackAutoScroll):Me(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Le(document,"dragover",this._handleAutoScroll):(Le(document,"pointermove",this._handleFallbackAutoScroll),Le(document,"touchmove",this._handleFallbackAutoScroll),Le(document,"mousemove",this._handleFallbackAutoScroll)),Ss(),un(),ef()},nulling:function(){pn=si=Ir=ai=Dr=ti=ri=null,Je.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,n){var o=this,s=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(s,i);if(pn=t,n||this.options.forceAutoScrollFallback||Mr||Ht||Lr){ni(t,this.options,a,n);var l=Kt(a,!0);ai&&(!Dr||s!==ti||i!==ri)&&(Dr&&Ss(),Dr=setInterval(function(){var u=Kt(document.elementFromPoint(s,i),!0);u!==l&&(l=u,un()),ni(t,o.options,u,n)},10),ti=s,ri=i)}else{if(!this.options.bubbleScroll||Kt(a,!0)===Ft()){un();return}ni(t,this.options,Kt(a,!1),!1)}}},jt(r,{pluginName:"scroll",initializeByDefault:!0})}function un(){Je.forEach(function(r){clearInterval(r.pid)}),Je=[]}function Ss(){clearInterval(Dr)}var ni=Is(function(r,e,t,n){if(!!e.scroll){var o=(r.touches?r.touches[0]:r).clientX,s=(r.touches?r.touches[0]:r).clientY,i=e.scrollSensitivity,a=e.scrollSpeed,l=Ft(),u=!1,c;si!==t&&(si=t,un(),Ir=e.scroll,c=e.scrollFn,Ir===!0&&(Ir=Kt(t,!0)));var f=0,d=Ir;do{var h=d,p=tt(h),g=p.top,y=p.bottom,b=p.left,x=p.right,k=p.width,S=p.height,O=void 0,C=void 0,P=h.scrollWidth,A=h.scrollHeight,D=ge(h),I=h.scrollLeft,M=h.scrollTop;h===l?(O=k<P&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),C=S<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(O=k<P&&(D.overflowX==="auto"||D.overflowX==="scroll"),C=S<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var N=O&&(Math.abs(x-o)<=i&&I+k<P)-(Math.abs(b-o)<=i&&!!I),B=C&&(Math.abs(y-s)<=i&&M+S<A)-(Math.abs(g-s)<=i&&!!M);if(!Je[f])for(var H=0;H<=f;H++)Je[H]||(Je[H]={});(Je[f].vx!=N||Je[f].vy!=B||Je[f].el!==h)&&(Je[f].el=h,Je[f].vx=N,Je[f].vy=B,clearInterval(Je[f].pid),(N!=0||B!=0)&&(u=!0,Je[f].pid=setInterval(function(){n&&this.layer===0&&ve.active._onTouchMove(pn);var Z=Je[this.layer].vy?Je[this.layer].vy*a:0,W=Je[this.layer].vx?Je[this.layer].vx*a:0;typeof c=="function"&&c.call(ve.dragged.parentNode[vt],W,Z,r,pn,Je[this.layer].el)!=="continue"||Ds(Je[this.layer].el,W,Z)}.bind({layer:f}),24))),f++}while(e.bubbleScroll&&d!==l&&(d=Kt(d,!1)));ai=u}},30),_s=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,i=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(!!t){var u=n||s;a();var c=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,f=document.elementFromPoint(c.clientX,c.clientY);l(),u&&!u.el.contains(f)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function ui(){}ui.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,n=e.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=fr(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(t,o):this.sortable.el.appendChild(t),this.sortable.animateAll(),n&&n.animateAll()},drop:_s};jt(ui,{pluginName:"revertOnSpill"});function ci(){}ci.prototype={onSpill:function(e){var t=e.dragEl,n=e.putSortable,o=n||this.sortable;o.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),o.animateAll()},drop:_s};jt(ci,{pluginName:"removeOnSpill"});ve.mount(new bf);ve.mount(ci,ui);var hr=ve;var Ns={name:function(r,e){let t=r.getAttribute("data-name").trim().toLowerCase(),n=e.getAttribute("data-name").trim().toLowerCase();return t.localeCompare(n)},created:function(r,e){let t=Number(r.getAttribute("data-created"));return Number(e.getAttribute("data-created"))-t},updated:function(r,e){let t=Number(r.getAttribute("data-updated"));return Number(e.getAttribute("data-updated"))-t},chaptersFirst:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?-1:1},chaptersLast:function(r,e){let t=r.getAttribute("data-type"),n=e.getAttribute("data-type");return t===n?0:t==="chapter"?1:-1}},di=class{constructor(e){this.elem=e,this.sortContainer=e.querySelector("[book-sort-boxes]"),this.input=e.querySelector("[book-sort-input]");let t=e.querySelector(".sort-box");this.setupBookSortable(t),this.setupSortPresets(),window.$events.listen("entity-select-confirm",this.bookSelect.bind(this))}setupSortPresets(){let e="",t=!1,n=["name","created","updated"];this.sortContainer.addEventListener("click",o=>{let s=o.target.closest(".sort-box-options [data-sort]");if(!s)return;o.preventDefault();let i=s.closest(".sort-box").querySelectorAll("ul"),a=s.getAttribute("data-sort");t=e===a?!t:!1;let l=Ns[a];t&&n.includes(a)&&(l=function(u,c){return 0-Ns[a](u,c)});for(let u of i)Array.from(u.children).filter(f=>f.matches("li")).sort(l).forEach(f=>{u.appendChild(f)});e=a,this.updateMapInput()})}bookSelect(e){if(this.elem.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=document.createElement("div");s.innerHTML=o.data;let i=s.children[0];this.sortContainer.append(i),this.setupBookSortable(i)})}setupBookSortable(e){let t=[e.querySelector(".sort-list")];t.push(...e.querySelectorAll(".entity-list-item + ul"));let n={name:"book",pull:["book","chapter"],put:["book","chapter"]},o={name:"chapter",pull:["book","chapter"],put:function(s,i,a){return a.getAttribute("data-type")==="page"}};for(let s of t)new hr(s,{group:s.classList.contains("sort-list")?n:o,animation:150,fallbackOnBody:!0,swapThreshold:.65,onSort:this.updateMapInput.bind(this),dragClass:"bg-white",ghostClass:"primary-background-light",multiDrag:!0,multiDragKey:"CTRL",selectedClass:"sortable-selected"})}updateMapInput(){let e=this.buildEntityMap();this.input.value=JSON.stringify(e)}buildEntityMap(){let e=[],t=this.elem.querySelectorAll(".sort-list");for(let n of t){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(i=>i.matches('[data-type="page"], [data-type="chapter"]'));for(let i=0;i<s.length;i++)this.addBookChildToMap(s[i],i,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),i=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:i,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let u=0;u<l.length;u++)o.push({id:l[u].getAttribute("data-id"),sort:u,parentChapter:a,type:"page",book:n})}},Bs=di;var gn=new WeakMap;function $s(r,e=400,t=null){Br(r),r.style.display="block",Nr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function vn(r,e=400,t=null){Br(r),Nr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function pr(r,e=400){Br(r);let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:[`${t}px`,"0px"],overflow:["hidden","hidden"],paddingTop:[o,"0px"],paddingBottom:[s,"0px"]};Nr(r,i,e,()=>{r.style.display="none"})}function mr(r,e=400){Br(r),r.style.display="block";let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom"),i={maxHeight:["0px",`${t}px`],overflow:["hidden","hidden"],paddingTop:["0px",o],paddingBottom:["0px",s]};Nr(r,i,e)}function Us(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{Br(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),u=a.getPropertyValue("padding-bottom"),c={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,u]};Nr(r,c,e)}}function Nr(r,e,t=400,n=null){let o=Object.keys(e);for(let i of o)r.style[i]=e[i][0];let s=()=>{for(let i of o)r.style[i]=null;r.style.transition=null,r.removeEventListener("transitionend",s),gn.delete(r),n&&n()};setTimeout(()=>{r.style.transition=`all ease-in-out ${t}ms`;for(let i of o)r.style[i]=e[i][1];r.addEventListener("transitionend",s),gn.set(r,s)},15)}function Br(r){gn.has(r)&&gn.get(r)()}var fi=class{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),mr(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),pr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}},zs=fi;var hi=class{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.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()}),Be(this.languageLinks,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),Jr(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Be(this.saveButton,e=>this.save()),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.languageInputChange(t)).then(()=>window.importVersioned("code")).then(o=>o.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.popup.components.popup.show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.popup.components.popup.hide(),this.addHistory()}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase(),n=!1;for(let o of this.languageLinks){let s=o.dataset.lang.toLowerCase().trim(),i=t&&s.startsWith(t);o.classList.toggle("active",i),i&&!n&&(o.scrollIntoView({block:"center",behavior:"smooth"}),n=!0)}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}},js=hi;var pi=class{constructor(e){e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}},Hs=pi;var mi=class{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}},qs=mi;var gi=class{constructor(e){this.elem=e,this.trigger=e.querySelector("[collapsible-trigger]"),this.content=e.querySelector("[collapsible-content]"),this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.elem.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),mr(this.content,300)}close(){this.elem.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),pr(this.content,300)}toggle(){this.elem.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}},Vs=gi;var vi=class{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Be(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return this.container.components.popup}sendResult(e){this.res&&(this.res(e),this.res=null)}},Gs=vi;var yi=class{constructor(e){this.elem=e,this.checkbox=e.querySelector("input[type=checkbox]"),this.display=e.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.elem.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}},Ws=yi;var bi=class{constructor(e){this.elem=e,this.dealtWith=!1,e.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.elem.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.elem)}),this.dealtWith=!0)}},Ys=bi;var xi=class{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.setupListeners(),this.hide=this.hide.bind(this)}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,s=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.direction==="right"?this.menu.style.right=`${t.right-t.width}px`:this.menu.style.left=`${t.left}px`,this.menu.style.width=`${t.width}px`,n=s?window.innerHeight-t.top-o/2:t.top),s?(this.menu.style.top="initial",this.menu.style.bottom=`${n}px`):(this.menu.style.top=`${n}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide.bind(this)),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let i=this.menu.querySelector("input");i!==null&&i.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.components.dropdown)e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.container.appendChild(this.menu)),this.showing=!1}getFocusable(){return Array.from(this.menu.querySelectorAll('[tabindex]:not([tabindex="-1"]),[href],button,input:not([type=hidden])'))}focusNext(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=this.getFocusable(),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}setupListeners(){this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Be(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&this.focusNext()});let e=t=>{t.key==="ArrowDown"||t.key==="ArrowRight"?(this.focusNext(),t.preventDefault()):t.key==="ArrowUp"||t.key==="ArrowLeft"?(this.focusPrevious(),t.preventDefault()):t.key==="Escape"&&(this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation())};this.container.addEventListener("keydown",e),this.moveMenu&&this.menu.addEventListener("keydown",e),this.menu.addEventListener("keydown ",t=>{t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.hide())})}},Ks=xi;var wi=class{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Ar(this.runAjaxSearch,300,!1)}onShow(){this.loadList()}onSearch(){let e=this.searchInput.value.toLowerCase().trim();this.localSearchSelector?this.runLocalSearch(e):(this.toggleLoading(!0),this.listContainerElem.innerHTML="",this.runAjaxSearch(e))}runAjaxSearch(e){this.loadList(e)}runLocalSearch(e){let t=this.listContainerElem.querySelectorAll(this.localSearchSelector);for(let n of t){let o=!e||n.textContent.toLowerCase().includes(e);n.style.display=o?"flex":"none",n.classList.toggle("hidden",!o)}}async loadList(e=""){this.listContainerElem.innerHTML="",this.toggleLoading(!0);try{let t=await window.$http.get(this.getAjaxUrl(e)),n=Us(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}},Xs=wi;var Qs=Yr(Zs());var Si=class{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new Qs.default(this.container,{addRemoveLinks:!0,dictRemoveFile:this.removeMessage,timeout:Number(window.uploadTimeout)||6e4,maxFilesize:this.uploadLimit,url:this.url,withCredentials:!0,init(){this.dz=this,this.dz.on("sending",e.onSending.bind(e)),this.dz.on("success",e.onSuccess.bind(e)),this.dz.on("error",e.onError.bind(e))}})}onSending(e,t,n){let o=window.document.querySelector("meta[name=token]").getAttribute("content");n.append("_token",o),t.ontimeout=s=>{this.dz.emit("complete",e),this.dz.emit("error",e,this.timeoutMessage)}}onSuccess(e,t){this.$emit("success",{file:e,data:t}),this.successMessage&&window.$events.emit("success",this.successMessage),vn(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let o=s=>{let i=e.previewElement.querySelector("[data-dz-errormessage]");i.textContent=s};n&&n.status===413?o(this.uploadLimitMessage):t.file&&o(t.file)}removeAll(){this.dz.removeAllFiles(!0)}},Js=Si;var Ci=class{constructor(e){this.elem=e,this.buttons=e.querySelectorAll("[toolbox-tab-button]"),this.contentElements=e.querySelectorAll("[toolbox-tab-content]"),this.toggleButton=e.querySelector("[toolbox-toggle]"),this.toggleButton.addEventListener("click",this.toggle.bind(this)),this.elem.addEventListener("click",t=>{let n=t.target.closest("[toolbox-tab-button]");if(n===null)return;let o=n.getAttribute("toolbox-tab-button");this.setActiveTab(o,!0)}),this.setActiveTab(this.contentElements[0].getAttribute("toolbox-tab-content"))}toggle(){this.elem.classList.toggle("open");let e=this.elem.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n=0,o=this.buttons.length;n<o;n++)this.buttons[n].classList.remove("active"),this.buttons[n].getAttribute("toolbox-tab-button")===e&&this.buttons[n].classList.add("active");for(let n=0,o=this.contentElements.length;n<o;n++)this.contentElements[n].style.display="none",this.contentElements[n].getAttribute("toolbox-tab-content")===e&&(this.contentElements[n].style.display="block");t&&!this.elem.classList.contains("open")&&this.toggle()}},ea=Ci;var Ai=class{constructor(e){this.permissionsTable=e.querySelector("[permissions-table]"),this.restrictedCheckbox=e.querySelector("[name=restricted]"),this.restrictedCheckbox.addEventListener("change",this.updateTableVisibility.bind(this))}updateTableVisibility(){this.permissionsTable.style.display=this.restrictedCheckbox.checked?null:"none"}},ta=Ai;var ki=class{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),Be(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}},ra=ki;var Ti=class{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.addButton=this.$refs.add,this.search="",this.lastClick=0,this.selectedItemData=null,this.setupListeners(),this.showLoading(),this.initialLoad()}setupListeners(){this.elem.addEventListener("click",this.onClick.bind(this));let e=0;this.searchInput.addEventListener("input",t=>{e=Date.now(),this.showLoading(),setTimeout(()=>{Date.now()-e<199||this.searchEntities(this.searchInput.value)},200)}),this.searchInput.addEventListener("keydown",t=>{t.keyCode===13&&t.preventDefault()}),this.addButton&&this.addButton.addEventListener("click",t=>{this.selectedItemData&&(this.confirmSelection(this.selectedItemData),this.unselectAll())}),We(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/ajax/search/entities?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(n=>{this.resultsContainer.innerHTML=n.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),n=e.getAttribute("data-entity-type"),o=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${o}`:"";let i=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:i};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}},na=Ti;var Ii=class{setup(){this.elem=this.$el,this.selectButton=this.$refs.select,window.EntitySelectorPopup=this,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e){this.callback=e,this.elem.components.popup.show(),this.getSelector().focusSearch()}hide(){this.elem.components.popup.hide()}getSelector(){return this.selectorEl.components["entity-selector"]}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}},ia=Ii;var Di=class{setup(){this.container=this.$el,this.name=this.$opts.name,Be(this.$el,()=>{this.$emit(this.name,this.$opts)})}},oa=Di;var Li=class{constructor(e){this.elem=e,this.isOpen=e.getAttribute("expand-toggle-is-open")==="yes",this.updateEndpoint=e.getAttribute("expand-toggle-update-endpoint"),this.selector=e.getAttribute("expand-toggle"),e.addEventListener("click",this.click.bind(this))}open(e){mr(e,200)}close(e){pr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.selector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}},sa=Li;var Fi=class{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}},aa=Fi;var Ri=class{constructor(e){this.elem=e,this.typeControl=e.querySelector('[name="setting-app-homepage-type"]'),this.pagePickerContainer=e.querySelector("[page-picker-container]"),this.typeControl.addEventListener("change",this.controlPagePickerVisibility.bind(this)),this.controlPagePickerVisibility()}controlPagePickerVisibility(){let e=this.typeControl.value==="page";this.pagePickerContainer.style.display=e?"block":"none"}},la=Ri;var Oi=class{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.formContainer=this.$refs.formContainer,this.dropzoneContainer=this.$refs.dropzoneContainer,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners(),window.ImageManager=this}setupListeners(){Be(this.filterTabs,e=>{this.resetAll(),this.filter=e.target.dataset.filter,this.setActiveFilterTab(this.filter),this.loadGallery()}),this.searchForm.addEventListener("submit",e=>{this.resetListView(),this.loadGallery(),e.preventDefault()}),Be(this.cancelSearch,e=>{this.resetListView(),this.resetSearchView(),this.loadGallery(),this.cancelSearch.classList.remove("active")}),this.searchInput.addEventListener("input",e=>{this.cancelSearch.classList.toggle("active",this.searchInput.value.trim())}),We(this.listContainer,".load-more","click",async e=>{Cr(e.target),this.page++,await this.loadGallery(),e.target.remove()}),this.listContainer.addEventListener("event-emit-select-image",this.onImageSelectEvent.bind(this)),this.listContainer.addEventListener("error",e=>{e.target.src=baseUrl("loading_error.png")},!0),Be(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),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),is(this.listContainer)}addReturnedHtmlElementsToList(e){let t=document.createElement("div");t.innerHTML=e,window.components.init(t);for(let n of[...t.children])this.listContainer.appendChild(n)}setActiveFilterTab(e){this.filterTabs.forEach(n=>n.classList.remove("selected"));let t=this.filterTabs.find(n=>n.dataset.filter===e);t&&t.classList.add("selected")}resetAll(){this.resetState(),this.resetListView(),this.resetSearchView(),this.resetEditForm(),this.setActiveFilterTab("all"),this.selectButton.classList.add("hidden")}resetSearchView(){this.searchInput.value=""}resetEditForm(){this.formContainer.innerHTML=""}resetListView(){Cr(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),o?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,window.components.init(this.formContainer)}},ua=Oi;var Pi=class{constructor(e){this.elem=e,this.imageElem=e.querySelector("img"),this.imageInput=e.querySelector("input[type=file]"),this.resetInput=e.querySelector("input[data-reset-input]"),this.removeInput=e.querySelector("input[data-remove-input]"),this.defaultImage=e.getAttribute("data-default-image"),e.querySelector('button[data-action="reset-image"]').addEventListener("click",this.reset.bind(this));let n=e.querySelector('button[data-action="remove-image"]');n&&n.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}},ca=Pi;var Mi=class{constructor(e){this.elem=e,this.menu=e.querySelector("ul"),this.sortInput=e.querySelector('[name="sort"]'),this.orderInput=e.querySelector('[name="order"]'),this.form=e.querySelector("form"),this.menu.addEventListener("click",t=>{t.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(t)}),this.elem.addEventListener("click",t=>{t.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(t)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let n=this.orderInput.value==="asc"?"desc":"asc";this.orderInput.value=n,e.preventDefault(),this.form.submit()}},da=Mi;var Dc=Yr(vc()),Lc=Yr(Ec());var ho=class{constructor(e){this.data=e}hasItems(){return Boolean(this.data)&&Boolean(this.data.types)&&this.data.types.length>0}containsTabularData(){let e=this.data.getData("text/rtf");return e&&e.includes("\\trowd")}getImages(){let e=this.data.types,t=this.data.files,n=[];for(let o of e)if(o.includes("image")){let s=this.data.getData(o);n.push(s.getAsFile())}for(let o of t)o.type.includes("image")&&n.push(o);return n}},Hr=ho;function jp(r,e){return document.createElement(r,e)}function Hp(r,e,t){return document.createElementNS(r,e,t)}function qp(){return document.createDocumentFragment()}function Vp(r){return document.createTextNode(r)}function Gp(r){return document.createComment(r)}function Wp(r,e,t){r.insertBefore(e,t)}function Yp(r,e){r.removeChild(e)}function Kp(r,e){r.appendChild(e)}function Xp(r){return r.parentNode}function Zp(r){return r.nextSibling}function Qp(r){return r.tagName}function Jp(r,e){r.textContent=e}function em(r){return r.textContent}function tm(r){return r.nodeType===1}function rm(r){return r.nodeType===3}function nm(r){return r.nodeType===8}function im(r){return r.nodeType===11}var On={createElement:jp,createElementNS:Hp,createTextNode:Vp,createDocumentFragment:qp,createComment:Gp,insertBefore:Wp,removeChild:Yp,appendChild:Kp,parentNode:Xp,nextSibling:Zp,tagName:Qp,setTextContent:Jp,getTextContent:em,isElement:tm,isText:rm,isComment:nm,isDocumentFragment:im};function qt(r,e,t,n,o){let s=e===void 0?void 0:e.key;return{sel:r,data:e,children:t,text:n,elm:o,key:s}}var Sc=Array.isArray;function Cc(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function po(r){return r===void 0}function pt(r){return r!==void 0}var mo=qt("",{},[],void 0,void 0);function qr(r,e){var t,n;let o=r.key===e.key,s=((t=r.data)===null||t===void 0?void 0:t.is)===((n=e.data)===null||n===void 0?void 0:n.is);return r.sel===e.sel&&o&&s}function sm(){throw new Error("The document fragment is not supported on this platform.")}function am(r,e){return r.isElement(e)}function lm(r,e){return r.isDocumentFragment(e)}function um(r,e,t){var n;let o={};for(let s=e;s<=t;++s){let i=(n=r[s])===null||n===void 0?void 0:n.key;i!==void 0&&(o[i]=s)}return o}var cm=["create","update","remove","destroy","pre","post"];function go(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:On;for(let p of cm)for(let g of r){let y=g[p];y!==void 0&&n[p].push(y)}function s(p){let g=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return qt(o.tagName(p).toLowerCase()+g+b,{},[],void 0,p)}function i(p){return qt(void 0,{},[],void 0,p)}function a(p,g){return function(){if(--g===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,g){var y,b,x,k;let S,O=p.data;if(O!==void 0){let A=(y=O.hook)===null||y===void 0?void 0:y.init;pt(A)&&(A(p),O=p.data)}let C=p.children,P=p.sel;if(P==="!")po(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(P!==void 0){let A=P.indexOf("#"),D=P.indexOf(".",A),I=A>0?A:P.length,M=D>0?D:P.length,N=A!==-1||D!==-1?P.slice(0,Math.min(I,M)):P,B=p.elm=pt(O)&&pt(S=O.ns)?o.createElementNS(S,N,O):o.createElement(N,O);for(I<M&&B.setAttribute("id",P.slice(I+1,M)),D>0&&B.setAttribute("class",P.slice(M+1).replace(/\./g," ")),S=0;S<n.create.length;++S)n.create[S](mo,p);if(Sc(C))for(S=0;S<C.length;++S){let Z=C[S];Z!=null&&o.appendChild(B,l(Z,g))}else Cc(p.text)&&o.appendChild(B,o.createTextNode(p.text));let H=p.data.hook;pt(H)&&((b=H.create)===null||b===void 0||b.call(H,mo,p),H.insert&&g.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let A=p.children;for(p.elm=((k=o.createDocumentFragment)!==null&&k!==void 0?k:sm)(),S=0;S<n.create.length;++S)n.create[S](mo,p);for(S=0;S<A.length;++S){let D=A[S];D!=null&&o.appendChild(p.elm,l(D,g))}}else p.elm=o.createTextNode(p.text);return p.elm}function u(p,g,y,b,x,k){for(;b<=x;++b){let S=y[b];S!=null&&o.insertBefore(p,l(S,k),g)}}function c(p){var g,y;let b=p.data;if(b!==void 0){(y=(g=b?.hook)===null||g===void 0?void 0:g.destroy)===null||y===void 0||y.call(g,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let k=p.children[x];k!=null&&typeof k!="string"&&c(k)}}}function f(p,g,y,b){for(var x,k;y<=b;++y){let S,O,C=g[y];if(C!=null)if(pt(C.sel)){c(C),S=n.remove.length+1,O=a(C.elm,S);for(let A=0;A<n.remove.length;++A)n.remove[A](C,O);let P=(k=(x=C?.data)===null||x===void 0?void 0:x.hook)===null||k===void 0?void 0:k.remove;pt(P)?P(C,O):O()}else o.removeChild(p,C.elm)}}function d(p,g,y,b){let x=0,k=0,S=g.length-1,O=g[0],C=g[S],P=y.length-1,A=y[0],D=y[P],I,M,N,B;for(;x<=S&&k<=P;)O==null?O=g[++x]:C==null?C=g[--S]:A==null?A=y[++k]:D==null?D=y[--P]:qr(O,A)?(h(O,A,b),O=g[++x],A=y[++k]):qr(C,D)?(h(C,D,b),C=g[--S],D=y[--P]):qr(O,D)?(h(O,D,b),o.insertBefore(p,O.elm,o.nextSibling(C.elm)),O=g[++x],D=y[--P]):qr(C,A)?(h(C,A,b),o.insertBefore(p,C.elm,O.elm),C=g[--S],A=y[++k]):(I===void 0&&(I=um(g,x,S)),M=I[A.key],po(M)?o.insertBefore(p,l(A,b),O.elm):(N=g[M],N.sel!==A.sel?o.insertBefore(p,l(A,b),O.elm):(h(N,A,b),g[M]=void 0,o.insertBefore(p,N.elm,O.elm))),A=y[++k]);k<=P&&(B=y[P+1]==null?null:y[P+1].elm,u(p,B,y,k,P,b)),x<=S&&f(p,g,x,S)}function h(p,g,y){var b,x,k,S,O,C,P,A;let D=(b=g.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,g);let I=g.elm=p.elm,M=p.children,N=g.children;if(p!==g){if(g.data!==void 0||pt(g.text)&&g.text!==p.text){(k=g.data)!==null&&k!==void 0||(g.data={}),(S=p.data)!==null&&S!==void 0||(p.data={});for(let B=0;B<n.update.length;++B)n.update[B](p,g);(P=(C=(O=g.data)===null||O===void 0?void 0:O.hook)===null||C===void 0?void 0:C.update)===null||P===void 0||P.call(C,p,g)}po(g.text)?pt(M)&&pt(N)?M!==N&&d(I,M,N,y):pt(N)?(pt(p.text)&&o.setTextContent(I,""),u(I,null,N,0,N.length-1,y)):pt(M)?f(I,M,0,M.length-1):pt(p.text)&&o.setTextContent(I,""):p.text!==g.text&&(pt(M)&&f(I,M,0,M.length-1),o.setTextContent(I,g.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,g)}}return function(g,y){let b,x,k,S=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(am(o,g)?g=s(g):lm(o,g)&&(g=i(g)),qr(g,y)?h(g,y,S):(x=g.elm,k=o.parentNode(x),l(y,S),k!==null&&(o.insertBefore(k,y.elm,o.nextSibling(x)),f(k,[g],0,0))),b=0;b<S.length;++b)S[b].data.hook.insert(S[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function vo(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&vo(s,o.children,o.sel)}}function Vr(r,e){let t=e!==void 0?e:On,n;if(t.isElement(r)){let o=r.id?"#"+r.id:"",s=r.getAttribute("class"),i=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+o+i,l={},u={},c={},f=[],d,h,p,g=r.attributes,y=r.childNodes;for(h=0,p=g.length;h<p;h++)d=g[h].nodeName,d[0]==="d"&&d[1]==="a"&&d[2]==="t"&&d[3]==="a"&&d[4]==="-"?u[d.slice(5)]=g[h].nodeValue||"":d!=="id"&&d!=="class"&&(l[d]=g[h].nodeValue);for(h=0,p=y.length;h<p;h++)f.push(Vr(y[h],e));return Object.keys(l).length>0&&(c.attrs=l),Object.keys(u).length>0&&(c.datasets=u),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&vo(c,f,a),qt(a,c,f,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),qt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),qt("!",{},[],n,r)):qt("",{},[],void 0,r)}var dm="http://www.w3.org/1999/xlink",fm="http://www.w3.org/XML/1998/namespace";function Ac(r,e){let t,n=e.elm,o=r.data.attrs,s=e.data.attrs;if(!(!o&&!s)&&o!==s){o=o||{},s=s||{};for(t in s){let i=s[t];o[t]!==i&&(i===!0?n.setAttribute(t,""):i===!1?n.removeAttribute(t):t.charCodeAt(0)!==120?n.setAttribute(t,i):t.charCodeAt(3)===58?n.setAttributeNS(fm,t,i):t.charCodeAt(5)===58?n.setAttributeNS(dm,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var yo={create:Ac,update:Ac};var Pn;function hm(){return Pn||(Pn=go([yo]),Pn)}function kc(r,e){let t=document.createElement("div");t.innerHTML=e,hm()(Vr(r),Vr(t))}var _t=null,wo,bo,xo;function pm(r,e,t){bo=e,xo=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tc),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),wo=new URL(r).origin}function mm(){Ic()}function Tc(r){if(!r.data||r.data.length<1||r.origin!==wo)return;let e=JSON.parse(r.data);e.event==="init"?ym():e.event==="exit"?Ic():e.event==="save"?vm(e):e.event==="export"?gm(e):e.event==="configure"&&bm()}function gm(r){xo&&xo(r.data)}function vm(r){Eo({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function ym(){!bo||bo().then(r=>{Eo({action:"load",autosave:1,xml:r})})}function bm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),Eo({action:"configure",config:r})}function Ic(){window.removeEventListener("message",Tc),_t&&document.body.removeChild(_t)}function Eo(r){_t.contentWindow.postMessage(JSON.stringify(r),wo)}async function xm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function wm(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var bt={show:pm,close:mm,upload:xm,load:wm};var So=class{setup(){this.elem=this.$el,this.pageId=this.$opts.pageId,this.textDirection=this.$opts.textDirection,this.imageUploadErrorText=this.$opts.imageUploadErrorText,this.serverUploadLimitText=this.$opts.serverUploadLimitText,this.markdown=new Dc.default({html:!0}),this.markdown.use(Lc.default,{label:!0}),this.display=this.elem.querySelector(".markdown-display"),this.displayStylesLoaded=!1,this.input=this.elem.querySelector("textarea"),this.cm=null,this.Code=null;let e=window.importVersioned("code").then(n=>(this.cm=n.markdownEditor(this.input),this.Code=n,this.cm));this.onMarkdownScroll=this.onMarkdownScroll.bind(this);let t=()=>{this.displayDoc=this.display.contentDocument,this.init(e)};this.display.contentDocument.readyState==="complete"?t():this.display.addEventListener("load",t.bind(this)),window.$events.emitPublic(this.elem,"editor-markdown::setup",{markdownIt:this.markdown,displayEl:this.display,codeMirrorInstance:this.cm})}init(e){let t=0;this.displayDoc.addEventListener("click",s=>{let i=Date.now()-t<300,a=s.target.closest("a");if(a!==null){s.preventDefault(),window.open(a.getAttribute("href"));return}let l=s.target.closest("[drawio-diagram]");if(l!==null&&i){this.actionEditDrawing(l);return}t=Date.now()}),this.elem.addEventListener("click",s=>{let i=s.target.closest("button[data-action]");if(i===null)return;let a=i.getAttribute("data-action");if(a==="insertImage"&&this.actionInsertImage(),a==="insertLink"&&this.actionShowLinkSelector(),a==="insertDrawing"&&(s.ctrlKey||s.metaKey)){this.actionShowImageManager();return}a==="insertDrawing"&&this.actionStartDrawing(),a==="fullscreen"&&this.actionFullScreen()}),this.elem.addEventListener("click",s=>{let i=s.target.closest(".editor-toolbar-label");if(!i)return;let a=this.elem.querySelectorAll(".markdown-editor-wrap");for(let l of a)l.classList.remove("active");i.closest(".markdown-editor-wrap").classList.add("active")}),e.then(s=>{this.codeMirrorSetup(s);let i=Ar(()=>this.Code.updateLayout(s),100,!1);new ResizeObserver(i).observe(this.elem)}),this.listenForBookStackEditorEvents();let o=new URL(window.location).searchParams.get("content-text");o&&this.scrollToText(o)}updateAndRender(){let e=this.cm.getValue();this.input.value=e;let t=this.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e);let n=this.getDisplayTarget();this.displayDoc.body.className="page-content",kc(n,t),this.loadStylesIntoDisplay()}getDisplayTarget(){let e=this.displayDoc.body;if(e.children.length===0){let t=document.createElement("div");this.displayDoc.body.append(t)}return e.children[0]}loadStylesIntoDisplay(){if(this.displayStylesLoaded)return;this.displayDoc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.displayDoc.documentElement.style.backgroundColor="#222",this.displayDoc.documentElement.classList.add("dark-mode")),this.displayDoc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.displayDoc.head.appendChild(n)}this.displayStylesLoaded=!0}onMarkdownScroll(e){let t=this.displayDoc.body.children;if(t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}codeMirrorSetup(e){let t=this;e.setOption("direction","ltr");let n=this.Code.getMetaKey(),o={};o[`${n}-Alt-I`]=function(d){let p=``,g=d.getCursor("from");d.replaceSelection(p),d.setCursor(g.line,g.ch+p.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('<p class="callout info">',"</p>")},e.setOption("extraKeys",o),e.on("change",(d,h)=>{this.updateAndRender()});let s=Ar(d=>{let h=d.getScrollInfo();if(h.top+h.clientHeight===h.height){this.onMarkdownScroll(-1);return}let g=d.lineAtHeight(h.top,"local"),y=d.getRange({line:0,ch:null},{line:g,ch:null}),k=new DOMParser().parseFromString(this.markdown.render(y),"text/html").documentElement.querySelectorAll("body > *");this.onMarkdownScroll(k.length)},100);e.on("scroll",d=>{s(d)}),e.on("paste",(d,h)=>{let p=new Hr(h.clipboardData||h.dataTransfer);if(!p.hasItems()||p.containsTabularData())return;let g=p.getImages();for(let y of g)c(y)}),e.on("drop",(d,h)=>{let p=h.dataTransfer.getData("bookstack/template");if(p){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.preventDefault(),window.$http.get(`/templates/${p}`).then(b=>{let x=b.data.markdown||b.data.html;d.replaceSelection(x)})}let g=new Hr(h.dataTransfer);if(g.hasItems()&&g.getImages().length>0){let y=d.coordsChar({left:h.pageX,top:h.pageY});d.setCursor(y),h.stopPropagation(),h.preventDefault();let b=g.getImages();for(let x of b)c(x)}});function i(d,h){let p=e.getValue(),g=e.listSelections();e.setValue(p.replace(d,h)),e.setSelections(g)}function a(d){let h=e.getCursor(),p=e.getLine(h.line),g=p.length,y=p.split(" ")[0];if(y===d){p=p.replace(`${d} `,""),e.replaceRange(p,{line:h.line,ch:0},{line:h.line,ch:g}),e.setCursor({line:h.line,ch:h.ch-(d.length+1)});return}let b=/^[#>`]/.test(y),x=0;b?(x=d.length-y.length,p=p.replace(y,d).trim()):d!==""&&(x=d.length+1,p=d+" "+p),e.replaceRange(p,{line:h.line,ch:0},{line:h.line,ch:g}),e.setCursor({line:h.line,ch:h.ch+x})}function l(d,h){let p=e.getCursor(),g=e.getLine(p.line),y=g.length,b=g;g.indexOf(d)===0&&g.slice(-h.length)===h?b=g.slice(d.length,g.length-h.length):b=`${d}${g}${h}`,e.replaceRange(b,{line:p.line,ch:0},{line:p.line,ch:y}),e.setCursor({line:p.line,ch:p.ch+d.length})}function u(d,h){let p=e.getSelection();if(p==="")return l(d,h);let g=p,y=0,b=0;p.indexOf(d)===0&&p.slice(-h.length)===h?(g=p.slice(d.length,p.length-h.length),b=-(h.length+d.length)):(g=`${d}${p}${h}`,b=d.length+h.length);let x=e.listSelections()[0];e.replaceSelection(g);let k=x.head.ch<=x.anchor.ch;x.head.ch+=k?y:b,x.anchor.ch+=k?b:y,e.setSelections([x])}function c(d){if(d===null||d.type.indexOf("image")!==0)return;let h="png";if(d.name){let O=d.name.match(/\.(.+)$/);O.length>1&&(h=O[1])}let p="image-"+Math.random().toString(16).slice(2),g=window.baseUrl(`/loading.gif#upload${p}`),y=e.getSelection(),b=``,x=e.getCursor();e.replaceSelection(b),e.setCursor({line:x.line,ch:x.ch+y.length+3});let k="image-"+Date.now()+"."+h,S=new FormData;S.append("file",d,k),S.append("uploaded_to",t.pageId),window.$http.post("/images/gallery",S).then(O=>{let C=`[](${O.data.url})`;i(b,C)}).catch(O=>{window.$events.emit("error",t.imageUploadErrorText),i(b,y),console.log(O)})}function f(){let d=e.getCursor("from"),h=e.getSelection()||"",p=`[${h}]()`;e.focus(),e.replaceSelection(p);let g=h===""?-3:-1;e.setCursor(d.line,d.ch+p.length+g)}this.updateAndRender()}actionInsertImage(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{let n=t.thumbs.display||t.url,o=this.cm.getSelection(),s="[]("+t.url+")";this.cm.focus(),this.cm.replaceSelection(s),this.cm.setCursor(e.line,e.ch+s.length)},"gallery")}actionShowImageManager(){let e=this.cm.getCursor("from");window.ImageManager.show(t=>{this.insertDrawing(t,e)},"drawio")}actionShowLinkSelector(){let e=this.cm.getCursor("from");window.EntitySelectorPopup.show(t=>{let o=`[${this.cm.getSelection()||t.name}](${t.link})`;this.cm.focus(),this.cm.replaceSelection(o),this.cm.setCursor(e.line,e.ch+o.length)})}getDrawioUrl(){let e=document.querySelector("[drawio-url]");return e?e.getAttribute("drawio-url"):!1}actionStartDrawing(){let e=this.getDrawioUrl();if(!e)return;let t=this.cm.getCursor("from");bt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),bt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.cm.focus(),this.cm.replaceSelection(n),this.cm.setCursor(t.line,t.ch+n.length)}actionEditDrawing(e){let t=this.getDrawioUrl();if(!t)return;let n=this.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");bt.show(t,()=>bt.load(o),s=>{let i={image:s,uploaded_to:Number(this.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,u=this.cm.getValue().split(`
`).map(c=>c.indexOf(`drawio-diagram="${o}"`)!==-1?l:c).join(`
`);this.cm.setValue(u),this.cm.setCursor(n),this.cm.focus(),bt.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+`