`);return n};Er.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};Wa.exports=Er});var ci=ne((iy,Ka)=>{"use strict";function It(){this.__rules__=[],this.__cache__=null}It.prototype.__find__=function(r){for(var e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===r)return e;return-1};It.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)})})};It.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};It.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};It.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};It.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null};It.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};It.prototype.enableOnly=function(r,e){Array.isArray(r)||(r=[r]),this.__rules__.forEach(function(t){t.enabled=!1}),this.enable(r,e)};It.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};It.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[]};Ka.exports=It});var Za=ne((oy,Xa)=>{"use strict";var Uh=/\r\n?|\n/g,zh=/\0/g;Xa.exports=function(e){var t;t=e.src.replace(Uh,`
`),t=t.replace(zh,"\uFFFD"),e.src=t}});var Ja=ne((sy,Qa)=>{"use strict";Qa.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 tl=ne((ay,el)=>{"use strict";el.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 nl=ne((ly,rl)=>{"use strict";var Hh=Be().arrayReplaceAt;function jh(r){return/^<a[>\s]/i.test(r)}function Vh(r){return/^<\/a\s*>/i.test(r)}rl.exports=function(e){var t,n,o,s,i,a,l,c,u,d,h,f,p,v,y,b,x=e.tokens,I;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"&&(jh(a.content)&&p>0&&p--,Vh(a.content)&&p++),!(p>0)&&a.type==="text"&&e.md.linkify.test(a.content)){for(u=a.content,I=e.md.linkify.match(u),l=[],f=a.level,h=0,I.length>0&&I[0].index===0&&t>0&&s[t-1].type==="text_special"&&(I=I.slice(1)),c=0;c<I.length;c++)v=I[c].url,y=e.md.normalizeLink(v),e.md.validateLink(y)&&(b=I[c].text,I[c].schema?I[c].schema==="mailto:"&&!/^mailto:/i.test(b)?b=e.md.normalizeLinkText("mailto:"+b).replace(/^mailto:/,""):b=e.md.normalizeLinkText(b):b=e.md.normalizeLinkText("http://"+b).replace(/^http:\/\//,""),d=I[c].index,d>h&&(i=new e.Token("text","",0),i.content=u.slice(h,d),i.level=f,l.push(i)),i=new e.Token("link_open","a",1),i.attrs=[["href",y]],i.level=f++,i.markup="linkify",i.info="auto",l.push(i),i=new e.Token("text","",0),i.content=b,i.level=f,l.push(i),i=new e.Token("link_close","a",-1),i.level=--f,i.markup="linkify",i.info="auto",l.push(i),h=I[c].lastIndex);h<u.length&&(i=new e.Token("text","",0),i.content=u.slice(h),i.level=f,l.push(i)),x[n].children=s=Hh(s,t,l)}}}}});var sl=ne((cy,ol)=>{"use strict";var il=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,qh=/\((c|tm|r)\)/i,Gh=/\((c|tm|r)\)/ig,Wh={c:"\xA9",r:"\xAE",tm:"\u2122"};function Yh(r,e){return Wh[e.toLowerCase()]}function Kh(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(Gh,Yh)),t.type==="link_open"&&t.info==="auto"&&n--,t.type==="link_close"&&t.info==="auto"&&n++}function Xh(r){var e,t,n=0;for(e=r.length-1;e>=0;e--)t=r[e],t.type==="text"&&!n&&il.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++}ol.exports=function(e){var t;if(!!e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(qh.test(e.tokens[t].content)&&Kh(e.tokens[t].children),il.test(e.tokens[t].content)&&Xh(e.tokens[t].children))}});var fl=ne((uy,hl)=>{"use strict";var al=Be().isWhiteSpace,ll=Be().isPunctChar,cl=Be().isMdAsciiPunct,Zh=/['"]/,ul=/['"]/g,dl="\u2019";function ui(r,e,t){return r.slice(0,e)+t+r.slice(e+1)}function Qh(r,e){var t,n,o,s,i,a,l,c,u,d,h,f,p,v,y,b,x,I,C,M,S;for(C=[],t=0;t<r.length;t++){for(n=r[t],l=r[t].level,x=C.length-1;x>=0&&!(C[x].level<=l);x--);if(C.length=x+1,n.type!=="text")continue;o=n.content,i=0,a=o.length;e:for(;i<a&&(ul.lastIndex=i,s=ul.exec(o),!!s);){if(y=b=!0,i=s.index+1,I=s[0]==="'",u=32,s.index-1>=0)u=o.charCodeAt(s.index-1);else for(x=t-1;x>=0&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x--)if(!!r[x].content){u=r[x].content.charCodeAt(r[x].content.length-1);break}if(d=32,i<a)d=o.charCodeAt(i);else for(x=t+1;x<r.length&&!(r[x].type==="softbreak"||r[x].type==="hardbreak");x++)if(!!r[x].content){d=r[x].content.charCodeAt(0);break}if(h=cl(u)||ll(String.fromCharCode(u)),f=cl(d)||ll(String.fromCharCode(d)),p=al(u),v=al(d),v?y=!1:f&&(p||h||(y=!1)),p?b=!1:h&&(v||f||(b=!1)),d===34&&s[0]==='"'&&u>=48&&u<=57&&(b=y=!1),y&&b&&(y=h,b=f),!y&&!b){I&&(n.content=ui(n.content,s.index,dl));continue}if(b){for(x=C.length-1;x>=0&&(c=C[x],!(C[x].level<l));x--)if(c.single===I&&C[x].level===l){c=C[x],I?(M=e.md.options.quotes[2],S=e.md.options.quotes[3]):(M=e.md.options.quotes[0],S=e.md.options.quotes[1]),n.content=ui(n.content,s.index,S),r[c.token].content=ui(r[c.token].content,c.pos,M),i+=S.length-1,c.token===t&&(i+=M.length-1),o=n.content,a=o.length,C.length=x;continue e}}y?C.push({token:t,pos:s.index,single:I,level:l}):b&&I&&(n.content=ui(n.content,s.index,dl))}}}hl.exports=function(e){var t;if(!!e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!=="inline"||!Zh.test(e.tokens[t].content)||Qh(e.tokens[t].children,e)}});var ml=ne((dy,pl)=>{"use strict";pl.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 di=ne((hy,gl)=>{"use strict";function Cr(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}Cr.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};Cr.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Cr.prototype.attrSet=function(e,t){var n=this.attrIndex(e),o=[e,t];n<0?this.attrPush(o):this.attrs[n]=o};Cr.prototype.attrGet=function(e){var t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n};Cr.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};gl.exports=Cr});var bl=ne((fy,yl)=>{"use strict";var Jh=di();function vl(r,e,t){this.src=r,this.env=t,this.tokens=[],this.inlineMode=!1,this.md=e}vl.prototype.Token=Jh;yl.exports=vl});var wl=ne((py,xl)=>{"use strict";var ef=ci(),No=[["normalize",Za()],["block",Ja()],["inline",tl()],["linkify",nl()],["replacements",sl()],["smartquotes",fl()],["text_join",ml()]];function Uo(){this.ruler=new ef;for(var r=0;r<No.length;r++)this.ruler.push(No[r][0],No[r][1])}Uo.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r)};Uo.prototype.State=bl();xl.exports=Uo});var Sl=ne((my,Cl)=>{"use strict";var zo=Be().isSpace;function Ho(r,e){var t=r.bMarks[e]+r.tShift[e],n=r.eMarks[e];return r.src.slice(t,n)}function El(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}Cl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,I,C,M,S;if(t+2>n||(u=t+1,e.sCount[u]<e.blkIndent)||e.sCount[u]-e.blkIndent>=4||(a=e.bMarks[u]+e.tShift[u],a>=e.eMarks[u])||(M=e.src.charCodeAt(a++),M!==124&&M!==45&&M!==58)||a>=e.eMarks[u]||(S=e.src.charCodeAt(a++),S!==124&&S!==45&&S!==58&&!zo(S))||M===45&&zo(S))return!1;for(;a<e.eMarks[u];){if(s=e.src.charCodeAt(a),s!==124&&s!==45&&s!==58&&!zo(s))return!1;a++}for(i=Ho(e,t+1),d=i.split("|"),p=[],l=0;l<d.length;l++){if(v=d[l].trim(),!v){if(l===0||l===d.length-1)continue;return!1}if(!/^:?-+:?$/.test(v))return!1;v.charCodeAt(v.length-1)===58?p.push(v.charCodeAt(0)===58?"center":"right"):v.charCodeAt(0)===58?p.push("left"):p.push("")}if(i=Ho(e,t).trim(),i.indexOf("|")===-1||e.sCount[t]-e.blkIndent>=4||(d=El(i),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),h=d.length,h===0||h!==p.length))return!1;if(o)return!0;for(x=e.parentType,e.parentType="table",C=e.md.block.ruler.getRules("blockquote"),f=e.push("table_open","table",1),f.map=y=[t,0],f=e.push("thead_open","thead",1),f.map=[t,t+1],f=e.push("tr_open","tr",1),f.map=[t,t+1],l=0;l<d.length;l++)f=e.push("th_open","th",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l].trim(),f.children=[],f=e.push("th_close","th",-1);for(f=e.push("tr_close","tr",-1),f=e.push("thead_close","thead",-1),u=t+2;u<n&&!(e.sCount[u]<e.blkIndent);u++){for(I=!1,l=0,c=C.length;l<c;l++)if(C[l](e,u,n,!0)){I=!0;break}if(I||(i=Ho(e,u).trim(),!i)||e.sCount[u]-e.blkIndent>=4)break;for(d=El(i),d.length&&d[0]===""&&d.shift(),d.length&&d[d.length-1]===""&&d.pop(),u===t+2&&(f=e.push("tbody_open","tbody",1),f.map=b=[t+2,0]),f=e.push("tr_open","tr",1),f.map=[u,u+1],l=0;l<h;l++)f=e.push("td_open","td",1),p[l]&&(f.attrs=[["style","text-align:"+p[l]]]),f=e.push("inline","",0),f.content=d[l]?d[l].trim():"",f.children=[],f=e.push("td_close","td",-1);f=e.push("tr_close","tr",-1)}return b&&(f=e.push("tbody_close","tbody",-1),b[1]=u),f=e.push("table_close","table",-1),y[1]=u,e.parentType=x,e.line=u,!0}});var kl=ne((gy,Al)=>{"use strict";Al.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 Il=ne((vy,Tl)=>{"use strict";Tl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h=!1,f=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||f+3>p||(s=e.src.charCodeAt(f),s!==126&&s!==96)||(c=f,f=e.skipChars(f,s),i=f-c,i<3)||(d=e.src.slice(c,f),a=e.src.slice(f,p),s===96&&a.indexOf(String.fromCharCode(s))>=0))return!1;if(o)return!0;for(l=t;l++,!(l>=n||(f=c=e.bMarks[l]+e.tShift[l],p=e.eMarks[l],f<p&&e.sCount[l]<e.blkIndent));)if(e.src.charCodeAt(f)===s&&!(e.sCount[l]-e.blkIndent>=4)&&(f=e.skipChars(f,s),!(f-c<i)&&(f=e.skipSpaces(f),!(f<p)))){h=!0;break}return i=e.sCount[t],e.line=l+(h?1:0),u=e.push("fence","code",0),u.info=a,u.content=e.getLines(t+1,l,i,!0),u.markup=d,u.map=[t,e.line],!0}});var Fl=ne((yy,Ll)=>{"use strict";var Dl=Be().isSpace;Ll.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,I,C,M,S,O,A,D=e.lineMax,T=e.bMarks[t]+e.tShift[t],P=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(T++)!==62)return!1;if(o)return!0;for(l=f=e.sCount[t]+1,e.src.charCodeAt(T)===32?(T++,l++,f++,s=!1,C=!0):e.src.charCodeAt(T)===9?(C=!0,(e.bsCount[t]+f)%4===3?(T++,l++,f++,s=!1):s=!0):C=!1,p=[e.bMarks[t]],e.bMarks[t]=T;T<P&&(i=e.src.charCodeAt(T),Dl(i));){i===9?f+=4-(f+e.bsCount[t]+(s?1:0))%4:f++;T++}for(v=[e.bsCount[t]],e.bsCount[t]=e.sCount[t]+1+(C?1:0),u=T>=P,x=[e.sCount[t]],e.sCount[t]=f-l,I=[e.tShift[t]],e.tShift[t]=T-e.bMarks[t],S=e.md.block.ruler.getRules("blockquote"),b=e.parentType,e.parentType="blockquote",h=t+1;h<n&&(A=e.sCount[h]<e.blkIndent,T=e.bMarks[h]+e.tShift[h],P=e.eMarks[h],!(T>=P));h++){if(e.src.charCodeAt(T++)===62&&!A){for(l=f=e.sCount[h]+1,e.src.charCodeAt(T)===32?(T++,l++,f++,s=!1,C=!0):e.src.charCodeAt(T)===9?(C=!0,(e.bsCount[h]+f)%4===3?(T++,l++,f++,s=!1):s=!0):C=!1,p.push(e.bMarks[h]),e.bMarks[h]=T;T<P&&(i=e.src.charCodeAt(T),Dl(i));){i===9?f+=4-(f+e.bsCount[h]+(s?1:0))%4:f++;T++}u=T>=P,v.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(C?1:0),x.push(e.sCount[h]),e.sCount[h]=f-l,I.push(e.tShift[h]),e.tShift[h]=T-e.bMarks[h];continue}if(u)break;for(M=!1,a=0,c=S.length;a<c;a++)if(S[a](e,h,n,!0)){M=!0;break}if(M){e.lineMax=h,e.blkIndent!==0&&(p.push(e.bMarks[h]),v.push(e.bsCount[h]),I.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}p.push(e.bMarks[h]),v.push(e.bsCount[h]),I.push(e.tShift[h]),x.push(e.sCount[h]),e.sCount[h]=-1}for(y=e.blkIndent,e.blkIndent=0,O=e.push("blockquote_open","blockquote",1),O.markup=">",O.map=d=[t,0],e.md.block.tokenize(e,t,h),O=e.push("blockquote_close","blockquote",-1),O.markup=">",e.lineMax=D,e.parentType=b,d[1]=e.line,a=0;a<I.length;a++)e.bMarks[a+t]=p[a],e.tShift[a+t]=I[a],e.sCount[a+t]=x[a],e.bsCount[a+t]=v[a];return e.blkIndent=y,!0}});var Ol=ne((by,Rl)=>{"use strict";var tf=Be().isSpace;Rl.exports=function(e,t,n,o){var s,i,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c++),s!==42&&s!==45&&s!==95))return!1;for(i=1;c<u;){if(a=e.src.charCodeAt(c++),a!==s&&!tf(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 _l=ne((xy,Bl)=>{"use strict";var $l=Be().isSpace;function Pl(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),!$l(s))?-1:n}function Ml(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),!$l(t))?-1:o}function rf(r,e){var t,n,o=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===o&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].hidden=!0,r.tokens[t].hidden=!0,t+=2)}Bl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,I,C,M,S,O,A,D,T,P,B,_,j,Q,Y,re=!1,ie=!0;if(e.sCount[t]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[t]-e.listIndent>=4&&e.sCount[t]<e.blkIndent)return!1;if(o&&e.parentType==="paragraph"&&e.sCount[t]>=e.blkIndent&&(re=!0),(P=Ml(e,t))>=0){if(d=!0,_=e.bMarks[t]+e.tShift[t],b=Number(e.src.slice(_,P-1)),re&&b!==1)return!1}else if((P=Pl(e,t))>=0)d=!1;else return!1;if(re&&e.skipSpaces(P)>=e.eMarks[t])return!1;if(y=e.src.charCodeAt(P-1),o)return!0;for(v=e.tokens.length,d?(Y=e.push("ordered_list_open","ol",1),b!==1&&(Y.attrs=[["start",b]])):Y=e.push("bullet_list_open","ul",1),Y.map=p=[t,0],Y.markup=String.fromCharCode(y),I=t,B=!1,Q=e.md.block.ruler.getRules("list"),S=e.parentType,e.parentType="list";I<n;){for(T=P,x=e.eMarks[I],u=C=e.sCount[I]+P-(e.bMarks[t]+e.tShift[t]);T<x;){if(s=e.src.charCodeAt(T),s===9)C+=4-(C+e.bsCount[I])%4;else if(s===32)C++;else break;T++}if(i=T,i>=x?c=1:c=C-u,c>4&&(c=1),l=u+c,Y=e.push("list_item_open","li",1),Y.markup=String.fromCharCode(y),Y.map=h=[t,0],d&&(Y.info=e.src.slice(_,P-1)),D=e.tight,A=e.tShift[t],O=e.sCount[t],M=e.listIndent,e.listIndent=e.blkIndent,e.blkIndent=l,e.tight=!0,e.tShift[t]=i-e.bMarks[t],e.sCount[t]=C,i>=x&&e.isEmpty(t+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,t,n,!0),(!e.tight||B)&&(ie=!1),B=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=M,e.tShift[t]=A,e.sCount[t]=O,e.tight=D,Y=e.push("list_item_close","li",-1),Y.markup=String.fromCharCode(y),I=t=e.line,h[1]=I,i=e.bMarks[t],I>=n||e.sCount[I]<e.blkIndent||e.sCount[t]-e.blkIndent>=4)break;for(j=!1,a=0,f=Q.length;a<f;a++)if(Q[a](e,I,n,!0)){j=!0;break}if(j)break;if(d){if(P=Ml(e,I),P<0)break;_=e.bMarks[I]+e.tShift[I]}else if(P=Pl(e,I),P<0)break;if(y!==e.src.charCodeAt(P-1))break}return d?Y=e.push("ordered_list_close","ol",-1):Y=e.push("bullet_list_close","ul",-1),Y.markup=String.fromCharCode(y),p[1]=I,e.line=I,e.parentType=S,ie&&rf(e,v),!0}});var Ul=ne((wy,Nl)=>{"use strict";var nf=Be().normalizeReference,hi=Be().isSpace;Nl.exports=function(e,t,n,o){var s,i,a,l,c,u,d,h,f,p,v,y,b,x,I,C,M=0,S=e.bMarks[t]+e.tShift[t],O=e.eMarks[t],A=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(S)!==91)return!1;for(;++S<O;)if(e.src.charCodeAt(S)===93&&e.src.charCodeAt(S-1)!==92){if(S+1===O||e.src.charCodeAt(S+1)!==58)return!1;break}for(l=e.lineMax,I=e.md.block.ruler.getRules("reference"),p=e.parentType,e.parentType="reference";A<l&&!e.isEmpty(A);A++)if(!(e.sCount[A]-e.blkIndent>3)&&!(e.sCount[A]<0)){for(x=!1,u=0,d=I.length;u<d;u++)if(I[u](e,A,l,!0)){x=!0;break}if(x)break}for(b=e.getLines(t,A,e.blkIndent,!1).trim(),O=b.length,S=1;S<O;S++){if(s=b.charCodeAt(S),s===91)return!1;if(s===93){f=S;break}else s===10?M++:s===92&&(S++,S<O&&b.charCodeAt(S)===10&&M++)}if(f<0||b.charCodeAt(f+1)!==58)return!1;for(S=f+2;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!hi(s))break;if(v=e.md.helpers.parseLinkDestination(b,S,O),!v.ok||(c=e.md.normalizeLink(v.str),!e.md.validateLink(c)))return!1;for(S=v.pos,M+=v.lines,i=S,a=M,y=S;S<O;S++)if(s=b.charCodeAt(S),s===10)M++;else if(!hi(s))break;for(v=e.md.helpers.parseLinkTitle(b,S,O),S<O&&y!==S&&v.ok?(C=v.str,S=v.pos,M+=v.lines):(C="",S=i,M=a);S<O&&(s=b.charCodeAt(S),!!hi(s));)S++;if(S<O&&b.charCodeAt(S)!==10&&C)for(C="",S=i,M=a;S<O&&(s=b.charCodeAt(S),!!hi(s));)S++;return S<O&&b.charCodeAt(S)!==10||(h=nf(b.slice(1,f)),!h)?!1:(o||(typeof e.env.references>"u"&&(e.env.references={}),typeof e.env.references[h]>"u"&&(e.env.references[h]={title:C,href:c}),e.parentType=p,e.line=t+M+1),!0)}});var Hl=ne((Ey,zl)=>{"use strict";zl.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 Vo=ne((Cy,jo)=>{"use strict";var of="[a-zA-Z_:][a-zA-Z0-9:._-]*",sf="[^\"'=<>`\\x00-\\x20]+",af="'[^']*'",lf='"[^"]*"',cf="(?:"+sf+"|"+af+"|"+lf+")",uf="(?:\\s+"+of+"(?:\\s*=\\s*"+cf+")?)",jl="<[A-Za-z][A-Za-z0-9\\-]*"+uf+"*\\s*\\/?>",Vl="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",df="<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->",hf="<[?][\\s\\S]*?[?]>",ff="<![A-Z]+\\s+[^>]*>",pf="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",mf=new RegExp("^(?:"+jl+"|"+Vl+"|"+df+"|"+hf+"|"+ff+"|"+pf+")"),gf=new RegExp("^(?:"+jl+"|"+Vl+")");jo.exports.HTML_TAG_RE=mf;jo.exports.HTML_OPEN_CLOSE_TAG_RE=gf});var Gl=ne((Sy,ql)=>{"use strict";var vf=Hl(),yf=Vo().HTML_OPEN_CLOSE_TAG_RE,Sr=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+vf.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(yf.source+"\\s*$"),/^$/,!1]];ql.exports=function(e,t,n,o){var s,i,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(c)!==60)return!1;for(l=e.src.slice(c,u),s=0;s<Sr.length&&!Sr[s][0].test(l);s++);if(s===Sr.length)return!1;if(o)return Sr[s][2];if(i=t+1,!Sr[s][1].test(l)){for(;i<n&&!(e.sCount[i]<e.blkIndent);i++)if(c=e.bMarks[i]+e.tShift[i],u=e.eMarks[i],l=e.src.slice(c,u),Sr[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 Kl=ne((Ay,Yl)=>{"use strict";var Wl=Be().isSpace;Yl.exports=function(e,t,n,o){var s,i,a,l,c=e.bMarks[t]+e.tShift[t],u=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||(s=e.src.charCodeAt(c),s!==35||c>=u))return!1;for(i=1,s=e.src.charCodeAt(++c);s===35&&c<u&&i<=6;)i++,s=e.src.charCodeAt(++c);return i>6||c<u&&!Wl(s)?!1:(o||(u=e.skipSpacesBack(u,c),a=e.skipCharsBack(u,35,c),a>c&&Wl(e.src.charCodeAt(a-1))&&(u=a),e.line=t+1,l=e.push("heading_open","h"+String(i),1),l.markup="########".slice(0,i),l.map=[t,e.line],l=e.push("inline","",0),l.content=e.src.slice(c,u).trim(),l.map=[t,e.line],l.children=[],l=e.push("heading_close","h"+String(i),-1),l.markup="########".slice(0,i)),!0)}});var Zl=ne((ky,Xl)=>{"use strict";Xl.exports=function(e,t,n){var o,s,i,a,l,c,u,d,h,f=t+1,p,v=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;for(p=e.parentType,e.parentType="paragraph";f<n&&!e.isEmpty(f);f++)if(!(e.sCount[f]-e.blkIndent>3)){if(e.sCount[f]>=e.blkIndent&&(c=e.bMarks[f]+e.tShift[f],u=e.eMarks[f],c<u&&(h=e.src.charCodeAt(c),(h===45||h===61)&&(c=e.skipChars(c,h),c=e.skipSpaces(c),c>=u)))){d=h===61?1:2;break}if(!(e.sCount[f]<0)){for(s=!1,i=0,a=v.length;i<a;i++)if(v[i](e,f,n,!0)){s=!0;break}if(s)break}}return d?(o=e.getLines(t,f,e.blkIndent,!1).trim(),e.line=f+1,l=e.push("heading_open","h"+String(d),1),l.markup=String.fromCharCode(h),l.map=[t,e.line],l=e.push("inline","",0),l.content=o,l.map=[t,e.line-1],l.children=[],l=e.push("heading_close","h"+String(d),-1),l.markup=String.fromCharCode(h),e.parentType=p,!0):!1}});var Jl=ne((Ty,Ql)=>{"use strict";Ql.exports=function(e,t){var n,o,s,i,a,l,c=t+1,u=e.md.block.ruler.getRules("paragraph"),d=e.lineMax;for(l=e.parentType,e.parentType="paragraph";c<d&&!e.isEmpty(c);c++)if(!(e.sCount[c]-e.blkIndent>3)&&!(e.sCount[c]<0)){for(o=!1,s=0,i=u.length;s<i;s++)if(u[s](e,c,d,!0)){o=!0;break}if(o)break}return n=e.getLines(t,c,e.blkIndent,!1).trim(),e.line=c,a=e.push("paragraph_open","p",1),a.map=[t,e.line],a=e.push("inline","",0),a.content=n,a.map=[t,e.line],a.children=[],a=e.push("paragraph_close","p",-1),e.parentType=l,!0}});var rc=ne((Iy,tc)=>{"use strict";var ec=di(),fi=Be().isSpace;function $t(r,e,t,n){var o,s,i,a,l,c,u,d;for(this.src=r,this.md=e,this.env=t,this.tokens=n,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0,this.result="",s=this.src,d=!1,i=a=c=u=0,l=s.length;a<l;a++){if(o=s.charCodeAt(a),!d)if(fi(o)){c++,o===9?u+=4-u%4:u++;continue}else d=!0;(o===10||a===l-1)&&(o!==10&&a++,this.bMarks.push(i),this.eMarks.push(a),this.tShift.push(c),this.sCount.push(u),this.bsCount.push(0),d=!1,c=0,u=0,i=a+1)}this.bMarks.push(s.length),this.eMarks.push(s.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}$t.prototype.push=function(r,e,t){var n=new ec(r,e,t);return n.block=!0,t<0&&this.level--,n.level=this.level,t>0&&this.level++,this.tokens.push(n),n};$t.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};$t.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};$t.prototype.skipSpaces=function(e){for(var t,n=this.src.length;e<n&&(t=this.src.charCodeAt(e),!!fi(t));e++);return e};$t.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!fi(this.src.charCodeAt(--e)))return e+1;return e};$t.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e};$t.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};$t.prototype.getLines=function(e,t,n,o){var s,i,a,l,c,u,d,h=e;if(e>=t)return"";for(u=new Array(t-e),s=0;h<t;h++,s++){for(i=0,d=l=this.bMarks[h],h+1<t||o?c=this.eMarks[h]+1:c=this.eMarks[h];l<c&&i<n;){if(a=this.src.charCodeAt(l),fi(a))a===9?i+=4-(i+this.bsCount[h])%4:i++;else if(l-d<this.tShift[h])i++;else break;l++}i>n?u[s]=new Array(i-n+1).join(" ")+this.src.slice(l,c):u[s]=this.src.slice(l,c)}return u.join("")};$t.prototype.Token=ec;tc.exports=$t});var ic=ne((Dy,nc)=>{"use strict";var bf=ci(),pi=[["table",Sl(),["paragraph","reference"]],["code",kl()],["fence",Il(),["paragraph","reference","blockquote","list"]],["blockquote",Fl(),["paragraph","reference","blockquote","list"]],["hr",Ol(),["paragraph","reference","blockquote","list"]],["list",_l(),["paragraph","reference","blockquote"]],["reference",Ul()],["html_block",Gl(),["paragraph","reference","blockquote"]],["heading",Kl(),["paragraph","reference","blockquote"]],["lheading",Zl()],["paragraph",Jl()]];function mi(){this.ruler=new bf;for(var r=0;r<pi.length;r++)this.ruler.push(pi[r][0],pi[r][1],{alt:(pi[r][2]||[]).slice()})}mi.prototype.tokenize=function(r,e,t){for(var n,o,s=this.ruler.getRules(""),i=s.length,a=e,l=!1,c=r.md.options.maxNesting;a<t&&(r.line=a=r.skipEmptyLines(a),!(a>=t||r.sCount[a]<r.blkIndent));){if(r.level>=c){r.line=t;break}for(o=0;o<i&&(n=s[o](r,a,t,!1),!n);o++);r.tight=!l,r.isEmpty(r.line-1)&&(l=!0),a=r.line,a<t&&r.isEmpty(a)&&(l=!0,a++,r.line=a)}};mi.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))};mi.prototype.State=rc();nc.exports=mi});var sc=ne((Ly,oc)=>{"use strict";function xf(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}}oc.exports=function(e,t){for(var n=e.pos;n<e.posMax&&!xf(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}});var lc=ne((Fy,ac)=>{"use strict";var wf=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;ac.exports=function(e,t){var n,o,s,i,a,l,c,u;return!e.md.options.linkify||e.linkLevel>0||(n=e.pos,o=e.posMax,n+3>o)||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47||(s=e.pending.match(wf),!s)||(i=s[1],a=e.md.linkify.matchAtStart(e.src.slice(n-i.length)),!a)||(l=a.url,l=l.replace(/\*+$/,""),c=e.md.normalizeLink(l),!e.md.validateLink(c))?!1:(t||(e.pending=e.pending.slice(0,-i.length),u=e.push("link_open","a",1),u.attrs=[["href",c]],u.markup="linkify",u.info="auto",u=e.push("text","",0),u.content=e.md.normalizeLinkText(l),u=e.push("link_close","a",-1),u.markup="linkify",u.info="auto"),e.pos+=l.length-i.length,!0)}});var uc=ne((Ry,cc)=>{"use strict";var Ef=Be().isSpace;cc.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&&Ef(e.src.charCodeAt(i));)i++;return e.pos=i,!0}});var hc=ne((Oy,dc)=>{"use strict";var Cf=Be().isSpace,Go=[];for(qo=0;qo<256;qo++)Go.push(0);var qo;"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){Go[r.charCodeAt(0)]=1});dc.exports=function(e,t){var n,o,s,i,a,l=e.pos,c=e.posMax;if(e.src.charCodeAt(l)!==92||(l++,l>=c))return!1;if(n=e.src.charCodeAt(l),n===10){for(t||e.push("hardbreak","br",0),l++;l<c&&(n=e.src.charCodeAt(l),!!Cf(n));)l++;return e.pos=l,!0}return i=e.src[l],n>=55296&&n<=56319&&l+1<c&&(o=e.src.charCodeAt(l+1),o>=56320&&o<=57343&&(i+=e.src[l+1],l++)),s="\\"+i,t||(a=e.push("text_special","",0),n<256&&Go[n]!==0?a.content=i:a.content=s,a.markup=s,a.info="escape"),e.pos=l+1,!0}});var pc=ne((Py,fc)=>{"use strict";fc.exports=function(e,t){var n,o,s,i,a,l,c,u,d=e.pos,h=e.src.charCodeAt(d);if(h!==96)return!1;for(n=d,d++,o=e.posMax;d<o&&e.src.charCodeAt(d)===96;)d++;if(s=e.src.slice(n,d),c=s.length,e.backticksScanned&&(e.backticks[c]||0)<=n)return t||(e.pending+=s),e.pos+=c,!0;for(a=l=d;(a=e.src.indexOf("`",l))!==-1;){for(l=a+1;l<o&&e.src.charCodeAt(l)===96;)l++;if(u=l-a,u===c)return t||(i=e.push("code_inline","code",0),i.markup=s,i.content=e.src.slice(d,a).replace(/\n/g," ").replace(/^ (.+) $/,"$1")),e.pos=l,!0;e.backticks[u]=a}return e.backticksScanned=!0,t||(e.pending+=s),e.pos+=c,!0}});var Yo=ne((My,Wo)=>{"use strict";Wo.exports.tokenize=function(e,t){var n,o,s,i,a,l=e.pos,c=e.src.charCodeAt(l);if(t||c!==126||(o=e.scanDelims(e.pos,!0),i=o.length,a=String.fromCharCode(c),i<2))return!1;for(i%2&&(s=e.push("text","",0),s.content=a,i--),n=0;n<i;n+=2)s=e.push("text","",0),s.content=a+a,e.delimiters.push({marker:c,length:0,token:e.tokens.length-1,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0};function mc(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)}}Wo.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(mc(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&mc(e,n[t].delimiters)}});var Xo=ne(($y,Ko)=>{"use strict";Ko.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 gc(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--))}Ko.exports.postProcess=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(gc(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&gc(e,n[t].delimiters)}});var yc=ne((By,vc)=>{"use strict";var Sf=Be().normalizeReference,Zo=Be().isSpace;vc.exports=function(e,t){var n,o,s,i,a,l,c,u,d,h="",f="",p=e.pos,v=e.posMax,y=e.pos,b=!0;if(e.src.charCodeAt(e.pos)!==91||(a=e.pos+1,i=e.md.helpers.parseLinkLabel(e,e.pos,!0),i<0))return!1;if(l=i+1,l<v&&e.src.charCodeAt(l)===40){for(b=!1,l++;l<v&&(o=e.src.charCodeAt(l),!(!Zo(o)&&o!==10));l++);if(l>=v)return!1;if(y=l,c=e.md.helpers.parseLinkDestination(e.src,l,e.posMax),c.ok){for(h=e.md.normalizeLink(c.str),e.md.validateLink(h)?l=c.pos:h="",y=l;l<v&&(o=e.src.charCodeAt(l),!(!Zo(o)&&o!==10));l++);if(c=e.md.helpers.parseLinkTitle(e.src,l,e.posMax),l<v&&y!==l&&c.ok)for(f=c.str,l=c.pos;l<v&&(o=e.src.charCodeAt(l),!(!Zo(o)&&o!==10));l++);}(l>=v||e.src.charCodeAt(l)!==41)&&(b=!0),l++}if(b){if(typeof e.env.references>"u")return!1;if(l<v&&e.src.charCodeAt(l)===91?(y=l+1,l=e.md.helpers.parseLinkLabel(e,l),l>=0?s=e.src.slice(y,l++):l=i+1):l=i+1,s||(s=e.src.slice(a,i)),u=e.env.references[Sf(s)],!u)return e.pos=p,!1;h=u.href,f=u.title}return t||(e.pos=a,e.posMax=i,d=e.push("link_open","a",1),d.attrs=n=[["href",h]],f&&n.push(["title",f]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,d=e.push("link_close","a",-1)),e.pos=l,e.posMax=v,!0}});var xc=ne((_y,bc)=>{"use strict";var Af=Be().normalizeReference,Qo=Be().isSpace;bc.exports=function(e,t){var n,o,s,i,a,l,c,u,d,h,f,p,v,y="",b=e.pos,x=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91||(l=e.pos+2,a=e.md.helpers.parseLinkLabel(e,e.pos+1,!1),a<0))return!1;if(c=a+1,c<x&&e.src.charCodeAt(c)===40){for(c++;c<x&&(o=e.src.charCodeAt(c),!(!Qo(o)&&o!==10));c++);if(c>=x)return!1;for(v=c,d=e.md.helpers.parseLinkDestination(e.src,c,e.posMax),d.ok&&(y=e.md.normalizeLink(d.str),e.md.validateLink(y)?c=d.pos:y=""),v=c;c<x&&(o=e.src.charCodeAt(c),!(!Qo(o)&&o!==10));c++);if(d=e.md.helpers.parseLinkTitle(e.src,c,e.posMax),c<x&&v!==c&&d.ok)for(h=d.str,c=d.pos;c<x&&(o=e.src.charCodeAt(c),!(!Qo(o)&&o!==10));c++);else h="";if(c>=x||e.src.charCodeAt(c)!==41)return e.pos=b,!1;c++}else{if(typeof e.env.references>"u")return!1;if(c<x&&e.src.charCodeAt(c)===91?(v=c+1,c=e.md.helpers.parseLinkLabel(e,c),c>=0?i=e.src.slice(v,c++):c=a+1):c=a+1,i||(i=e.src.slice(l,a)),u=e.env.references[Af(i)],!u)return e.pos=b,!1;y=u.href,h=u.title}return t||(s=e.src.slice(l,a),e.md.inline.parse(s,e.md,e.env,p=[]),f=e.push("image","img",0),f.attrs=n=[["src",y],["alt",""]],f.children=p,f.content=s,h&&n.push(["title",h])),e.pos=c,e.posMax=x,!0}});var Ec=ne((Ny,wc)=>{"use strict";var kf=/^([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])?)*)$/,Tf=/^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$/;wc.exports=function(e,t){var n,o,s,i,a,l,c=e.pos;if(e.src.charCodeAt(c)!==60)return!1;for(a=e.pos,l=e.posMax;;){if(++c>=l||(i=e.src.charCodeAt(c),i===60))return!1;if(i===62)break}return n=e.src.slice(a+1,c),Tf.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):kf.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 Sc=ne((Uy,Cc)=>{"use strict";var If=Vo().HTML_TAG_RE;function Df(r){return/^<a[>\s]/i.test(r)}function Lf(r){return/^<\/a\s*>/i.test(r)}function Ff(r){var e=r|32;return e>=97&&e<=122}Cc.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&&!Ff(n))||(o=e.src.slice(a).match(If),!o)?!1:(t||(i=e.push("html_inline","",0),i.content=e.src.slice(a,a+o[0].length),Df(i.content)&&e.linkLevel++,Lf(i.content)&&e.linkLevel--),e.pos+=o[0].length,!0)}});var Ic=ne((zy,Tc)=>{"use strict";var Ac=Po(),Rf=Be().has,Of=Be().isValidEntityCode,kc=Be().fromCodePoint,Pf=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Mf=/^&([a-z][a-z0-9]{1,31});/i;Tc.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(Pf),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=Of(o)?kc(o):kc(65533),i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0}else if(s=e.src.slice(a).match(Mf),s&&Rf(Ac,s[1]))return t||(i=e.push("text_special","",0),i.content=Ac[s[1]],i.markup=s[0],i.info="entity"),e.pos+=s[0].length,!0;return!1}});var Fc=ne((Hy,Lc)=>{"use strict";function Dc(r,e){var t,n,o,s,i,a,l,c,u={},d=e.length;if(!!d){var h=0,f=-2,p=[];for(t=0;t<d;t++)if(o=e[t],p.push(0),(e[h].marker!==o.marker||f!==o.token-1)&&(h=t),f=o.token,o.length=o.length||0,!!o.close){for(u.hasOwnProperty(o.marker)||(u[o.marker]=[-1,-1,-1,-1,-1,-1]),i=u[o.marker][(o.open?3:0)+o.length%3],n=h-p[h]-1,a=n;n>i;n-=p[n]+1)if(s=e[n],s.marker===o.marker&&s.open&&s.end<0&&(l=!1,(s.close||o.open)&&(s.length+o.length)%3===0&&(s.length%3!==0||o.length%3!==0)&&(l=!0),!l)){c=n>0&&!e[n-1].open?p[n-1]+1:0,p[t]=t-n+c,p[n]=c,o.open=!1,s.end=t,s.close=!1,a=-1,f=-2;break}a!==-1&&(u[o.marker][(o.open?3:0)+(o.length||0)%3]=a)}}}Lc.exports=function(e){var t,n=e.tokens_meta,o=e.tokens_meta.length;for(Dc(e,e.delimiters),t=0;t<o;t++)n[t]&&n[t].delimiters&&Dc(e,n[t].delimiters)}});var Oc=ne((jy,Rc)=>{"use strict";Rc.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 _c=ne((Vy,Bc)=>{"use strict";var Jo=di(),Pc=Be().isWhiteSpace,Mc=Be().isPunctChar,$c=Be().isMdAsciiPunct;function Kr(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}Kr.prototype.pushPending=function(){var r=new Jo("text","",0);return r.content=this.pending,r.level=this.pendingLevel,this.tokens.push(r),this.pending="",r};Kr.prototype.push=function(r,e,t){this.pending&&this.pushPending();var n=new Jo(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};Kr.prototype.scanDelims=function(r,e){var t=r,n,o,s,i,a,l,c,u,d,h=!0,f=!0,p=this.posMax,v=this.src.charCodeAt(r);for(n=r>0?this.src.charCodeAt(r-1):32;t<p&&this.src.charCodeAt(t)===v;)t++;return s=t-r,o=t<p?this.src.charCodeAt(t):32,c=$c(n)||Mc(String.fromCharCode(n)),d=$c(o)||Mc(String.fromCharCode(o)),l=Pc(n),u=Pc(o),u?h=!1:d&&(l||c||(h=!1)),l?f=!1:c&&(u||d||(f=!1)),e?(i=h,a=f):(i=h&&(!f||c),a=f&&(!h||d)),{can_open:i,can_close:a,length:s}};Kr.prototype.Token=Jo;Bc.exports=Kr});var zc=ne((qy,Uc)=>{"use strict";var Nc=ci(),es=[["text",sc()],["linkify",lc()],["newline",uc()],["escape",hc()],["backticks",pc()],["strikethrough",Yo().tokenize],["emphasis",Xo().tokenize],["link",yc()],["image",xc()],["autolink",Ec()],["html_inline",Sc()],["entity",Ic()]],ts=[["balance_pairs",Fc()],["strikethrough",Yo().postProcess],["emphasis",Xo().postProcess],["fragments_join",Oc()]];function Xr(){var r;for(this.ruler=new Nc,r=0;r<es.length;r++)this.ruler.push(es[r][0],es[r][1]);for(this.ruler2=new Nc,r=0;r<ts.length;r++)this.ruler2.push(ts[r][0],ts[r][1])}Xr.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};Xr.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()};Xr.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)};Xr.prototype.State=_c();Uc.exports=Xr});var jc=ne((Gy,Hc)=>{"use strict";Hc.exports=function(r){var e={};r=r||{},e.src_Any=$o().source,e.src_Cc=Bo().source,e.src_Z=_o().source,e.src_P=ii().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 Yc=ne((Wy,Wc)=>{"use strict";function rs(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 vi(r){return Object.prototype.toString.call(r)}function $f(r){return vi(r)==="[object String]"}function Bf(r){return vi(r)==="[object Object]"}function _f(r){return vi(r)==="[object RegExp]"}function Vc(r){return vi(r)==="[object Function]"}function Nf(r){return r.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}var Gc={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function Uf(r){return Object.keys(r||{}).reduce(function(e,t){return e||Gc.hasOwnProperty(t)},!1)}var zf={"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}}},Hf="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]",jf="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|\u0440\u0444".split("|");function Vf(r){r.__index__=-1,r.__text_cache__=""}function qf(r){return function(e,t){var n=e.slice(t);return r.test(n)?n.match(r)[0].length:0}}function qc(){return function(r,e){e.normalize(r)}}function gi(r){var e=r.re=jc()(r.__opts__),t=r.__tlds__.slice();r.onCompile(),r.__tlds_replaced__||t.push(Hf),t.push(e.src_xn),e.src_tlds=t.join("|");function n(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(n(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(n(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(n(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(n(e.tpl_host_fuzzy_test),"i");var o=[];r.__compiled__={};function s(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(r.__schemas__).forEach(function(a){var l=r.__schemas__[a];if(l!==null){var c={validate:null,link:null};if(r.__compiled__[a]=c,Bf(l)){_f(l.validate)?c.validate=qf(l.validate):Vc(l.validate)?c.validate=l.validate:s(a,l),Vc(l.normalize)?c.normalize=l.normalize:l.normalize?s(a,l):c.normalize=qc();return}if($f(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:qc()};var i=Object.keys(r.__compiled__).filter(function(a){return a.length>0&&r.__compiled__[a]}).map(Nf).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"),Vf(r)}function Gf(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 ns(r,e){var t=new Gf(r,e);return r.__compiled__[t.schema].normalize(t,r),t}function xt(r,e){if(!(this instanceof xt))return new xt(r,e);e||Uf(r)&&(e=r,r={}),this.__opts__=rs({},Gc,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=rs({},zf,r),this.__compiled__={},this.__tlds__=jf,this.__tlds_replaced__=!1,this.re={},gi(this)}xt.prototype.add=function(e,t){return this.__schemas__[e]=t,gi(this),this};xt.prototype.set=function(e){return this.__opts__=rs(this.__opts__,e),this};xt.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;var t,n,o,s,i,a,l,c,u;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(t=l.exec(e))!==null;)if(s=this.testSchemaAt(e,t[2],l.lastIndex),s){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+s;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(n=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(i=n.index+n[1].length,(this.__index__<0||i<this.__index__)&&(this.__schema__="",this.__index__=i,this.__last_index__=n.index+n[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(u=e.indexOf("@"),u>=0&&(o=e.match(this.re.email_fuzzy))!==null&&(i=o.index+o[1].length,a=o.index+o[0].length,(this.__index__<0||i<this.__index__||i===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=i,this.__last_index__=a))),this.__index__>=0};xt.prototype.pretest=function(e){return this.re.pretest.test(e)};xt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0};xt.prototype.match=function(e){var t=0,n=[];this.__index__>=0&&this.__text_cache__===e&&(n.push(ns(this,t)),t=this.__last_index__);for(var o=t?e.slice(t):e;this.test(o);)n.push(ns(this,t)),o=o.slice(this.__last_index__),t+=this.__last_index__;return n.length?n:null};xt.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,ns(this,0)):null};xt.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(),gi(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,gi(this),this)};xt.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};xt.prototype.onCompile=function(){};Wc.exports=xt});var ru={};no(ru,{decode:()=>as,default:()=>ep,encode:()=>ls,toASCII:()=>tu,toUnicode:()=>eu,ucs2decode:()=>ss,ucs2encode:()=>Qc});function or(r){throw new RangeError(Xf[r])}function Zf(r,e){let t=[],n=r.length;for(;n--;)t[n]=e(r[n]);return t}function Zc(r,e){let t=r.split("@"),n="";t.length>1&&(n=t[0]+"@",r=t[1]),r=r.replace(Kf,".");let o=r.split("."),s=Zf(o,e).join(".");return n+s}function ss(r){let e=[],t=0,n=r.length;for(;t<n;){let o=r.charCodeAt(t++);if(o>=55296&&o<=56319&&t<n){let s=r.charCodeAt(t++);(s&64512)==56320?e.push(((o&1023)<<10)+(s&1023)+65536):(e.push(o),t--)}else e.push(o)}return e}var Xc,Wf,Yf,Kf,Xf,is,Bt,os,Qc,Qf,Kc,Jc,as,ls,eu,tu,Jf,ep,nu=ud(()=>{"use strict";Xc="-",Wf=/^xn--/,Yf=/[^\0-\x7E]/,Kf=/[\x2E\u3002\uFF0E\uFF61]/g,Xf={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},is=36-1,Bt=Math.floor,os=String.fromCharCode;Qc=r=>String.fromCodePoint(...r),Qf=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36},Kc=function(r,e){return r+22+75*(r<26)-((e!=0)<<5)},Jc=function(r,e,t){let n=0;for(r=t?Bt(r/700):r>>1,r+=Bt(r/e);r>is*26>>1;n+=36)r=Bt(r/is);return Bt(n+(is+1)*r/(r+38))},as=function(r){let e=[],t=r.length,n=0,o=128,s=72,i=r.lastIndexOf(Xc);i<0&&(i=0);for(let a=0;a<i;++a)r.charCodeAt(a)>=128&&or("not-basic"),e.push(r.charCodeAt(a));for(let a=i>0?i+1:0;a<t;){let l=n;for(let u=1,d=36;;d+=36){a>=t&&or("invalid-input");let h=Qf(r.charCodeAt(a++));(h>=36||h>Bt((2147483647-n)/u))&&or("overflow"),n+=h*u;let f=d<=s?1:d>=s+26?26:d-s;if(h<f)break;let p=36-f;u>Bt(2147483647/p)&&or("overflow"),u*=p}let c=e.length+1;s=Jc(n-l,c,l==0),Bt(n/c)>2147483647-o&&or("overflow"),o+=Bt(n/c),n%=c,e.splice(n++,0,o)}return String.fromCodePoint(...e)},ls=function(r){let e=[];r=ss(r);let t=r.length,n=128,o=0,s=72;for(let l of r)l<128&&e.push(os(l));let i=e.length,a=i;for(i&&e.push(Xc);a<t;){let l=2147483647;for(let u of r)u>=n&&u<l&&(l=u);let c=a+1;l-n>Bt((2147483647-o)/c)&&or("overflow"),o+=(l-n)*c,n=l;for(let u of r)if(u<n&&++o>2147483647&&or("overflow"),u==n){let d=o;for(let h=36;;h+=36){let f=h<=s?1:h>=s+26?26:h-s;if(d<f)break;let p=d-f,v=36-f;e.push(os(Kc(f+p%v,0))),d=Bt(p/v)}e.push(os(Kc(d,0))),s=Jc(o,c,a==i),o=0,++a}++o,++n}return e.join("")},eu=function(r){return Zc(r,function(e){return Wf.test(e)?as(e.slice(4).toLowerCase()):e})},tu=function(r){return Zc(r,function(e){return Yf.test(e)?"xn--"+ls(e):e})},Jf={version:"2.1.0",ucs2:{decode:ss,encode:Qc},decode:as,encode:ls,toASCII:tu,toUnicode:eu},ep=Jf});var ou=ne((Yy,iu)=>{"use strict";iu.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 au=ne((Ky,su)=>{"use strict";su.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 cu=ne((Xy,lu)=>{"use strict";lu.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 fu=ne((Zy,hu)=>{"use strict";var Zr=Be(),tp=Ga(),rp=Ya(),np=wl(),ip=ic(),op=zc(),sp=Yc(),sr=Mo(),uu=(nu(),dd(ru)),ap={default:ou(),zero:au(),commonmark:cu()},lp=/^(vbscript|javascript|file|data):/,cp=/^data:image\/(gif|png|jpeg|webp);/;function up(r){var e=r.trim().toLowerCase();return lp.test(e)?!!cp.test(e):!0}var du=["http:","https:","mailto:"];function dp(r){var e=sr.parse(r,!0);if(e.hostname&&(!e.protocol||du.indexOf(e.protocol)>=0))try{e.hostname=uu.toASCII(e.hostname)}catch{}return sr.encode(sr.format(e))}function hp(r){var e=sr.parse(r,!0);if(e.hostname&&(!e.protocol||du.indexOf(e.protocol)>=0))try{e.hostname=uu.toUnicode(e.hostname)}catch{}return sr.decode(sr.format(e),sr.decode.defaultChars+"%")}function At(r,e){if(!(this instanceof At))return new At(r,e);e||Zr.isString(r)||(e=r||{},r="default"),this.inline=new op,this.block=new ip,this.core=new np,this.renderer=new rp,this.linkify=new sp,this.validateLink=up,this.normalizeLink=dp,this.normalizeLinkText=hp,this.utils=Zr,this.helpers=Zr.assign({},tp),this.options={},this.configure(r),e&&this.set(e)}At.prototype.set=function(r){return Zr.assign(this.options,r),this};At.prototype.configure=function(r){var e=this,t;if(Zr.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};At.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};At.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};At.prototype.use=function(r){var e=[this].concat(Array.prototype.slice.call(arguments,1));return r.apply(r,e),this};At.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};At.prototype.render=function(r,e){return e=e||{},this.renderer.render(this.parse(r,e),this.options,e)};At.prototype.parseInline=function(r,e){var t=new this.core.State(r,this,e);return t.inlineMode=!0,this.core.process(t),t.tokens};At.prototype.renderInline=function(r,e){return e=e||{},this.renderer.render(this.parseInline(r,e),this.options,e)};hu.exports=At});var mu=ne((Qy,pu)=>{"use strict";pu.exports=fu()});var xu=ne((Jy,bu)=>{var cs=!0,vu=!1,yu=!1;bu.exports=function(r,e){e&&(cs=!e.enabled,vu=!!e.label,yu=!!e.labelAfter),r.core.ruler.after("inline","github-task-lists",function(t){for(var n=t.tokens,o=2;o<n.length;o++)pp(n,o)&&(mp(n[o],t.Token),gu(n[o-2],"class","task-list-item"+(cs?"":" enabled")),gu(n[fp(n,o-2)],"class","contains-task-list"))})};function gu(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 pp(r,e){return xp(r[e])&&wp(r[e-1])&&Ep(r[e-2])&&Cp(r[e])}function mp(r,e){if(r.children.unshift(gp(r,e)),r.children[1].content=r.children[1].content.slice(3),r.content=r.content.slice(3),vu)if(yu){r.children.pop();var t="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);r.children[0].content=r.children[0].content.slice(0,-1)+' id="'+t+'">',r.children.push(bp(r.content,t,e))}else r.children.unshift(vp(e)),r.children.push(yp(e))}function gp(r,e){var t=new e("html_inline","",0),n=cs?' 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 vp(r){var e=new r("html_inline","",0);return e.content="<label>",e}function yp(r){var e=new r("html_inline","",0);return e.content="</label>",e}function bp(r,e,t){var n=new t("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+e+'">'+r+"</label>",n.attrs=[{for:e}],n}function xp(r){return r.type==="inline"}function wp(r){return r.type==="paragraph_open"}function Ep(r){return r.type==="list_item_open"}function Cp(r){return r.content.indexOf("[ ] ")===0||r.content.indexOf("[x] ")===0||r.content.indexOf("[X] ")===0}});var Pu=ne((tn,xs)=>{(function(r,e){typeof tn=="object"&&typeof xs=="object"?xs.exports=e():typeof define=="function"&&define.amd?define([],e):typeof tn=="object"?tn.ClipboardJS=e():r.ClipboardJS=e()})(tn,function(){return e={686:function(n,l,s){"use strict";s.d(l,{default:function(){return S}});var l=s(279),i=s.n(l),l=s(370),a=s.n(l),l=s(817),c=s.n(l);function u(O){try{return document.execCommand(O)}catch{return}}var d=function(O){return O=c()(O),u("cut"),O};function h(P,A){var D,T,P=(D=P,T=document.documentElement.getAttribute("dir")==="rtl",(P=document.createElement("textarea")).style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[T?"right":"left"]="-9999px",T=window.pageYOffset||document.documentElement.scrollTop,P.style.top="".concat(T,"px"),P.setAttribute("readonly",""),P.value=D,P);return A.container.appendChild(P),A=c()(P),u("copy"),P.remove(),A}var f=function(O){var A=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";return typeof O=="string"?D=h(O,A):O instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(O?.type)?D=h(O.value,A):(D=c()(O),u("copy")),D};function p(O){return(p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}var v=function(){var T=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},D=T.action,O=D===void 0?"copy":D,A=T.container,D=T.target,T=T.text;if(O!=="copy"&&O!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0){if(!D||p(D)!=="object"||D.nodeType!==1)throw new Error('Invalid "target" value, use a valid Element');if(O==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(O==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}return T?f(T,{container:A}):D?O==="cut"?d(D):f(D,{container:A}):void 0};function y(O){return(y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A})(O)}function b(O,A){for(var D=0;D<A.length;D++){var T=A[D];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(O,T.key,T)}}function x(O,A){return(x=Object.setPrototypeOf||function(D,T){return D.__proto__=T,D})(O,A)}function I(O){var A=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}();return function(){var D,T=C(O);return D=A?(D=C(this).constructor,Reflect.construct(T,arguments,D)):T.apply(this,arguments),T=this,!(D=D)||y(D)!=="object"&&typeof D!="function"?function(P){if(P!==void 0)return P;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(T):D}}function C(O){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)})(O)}function M(O,A){if(O="data-clipboard-".concat(O),A.hasAttribute(O))return A.getAttribute(O)}var S=function(){(function(B,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");B.prototype=Object.create(_&&_.prototype,{constructor:{value:B,writable:!0,configurable:!0}}),_&&x(B,_)})(P,i());var O,A,D,T=I(P);function P(B,_){var j;return function(Q){if(!(Q instanceof P))throw new TypeError("Cannot call a class as a function")}(this),(j=T.call(this)).resolveOptions(_),j.listenClick(B),j}return O=P,D=[{key:"copy",value:function(B){var _=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{container:document.body};return f(B,_)}},{key:"cut",value:function(B){return d(B)}},{key:"isSupported",value:function(){var B=0<arguments.length&&arguments[0]!==void 0?arguments[0]:["copy","cut"],B=typeof B=="string"?[B]:B,_=!!document.queryCommandSupported;return B.forEach(function(j){_=_&&!!document.queryCommandSupported(j)}),_}}],(A=[{key:"resolveOptions",value:function(){var B=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof B.action=="function"?B.action:this.defaultAction,this.target=typeof B.target=="function"?B.target:this.defaultTarget,this.text=typeof B.text=="function"?B.text:this.defaultText,this.container=y(B.container)==="object"?B.container:document.body}},{key:"listenClick",value:function(B){var _=this;this.listener=a()(B,"click",function(j){return _.onClick(j)})}},{key:"onClick",value:function(Q){var _=Q.delegateTarget||Q.currentTarget,j=this.action(_)||"copy",Q=v({action:j,container:this.container,target:this.target(_),text:this.text(_)});this.emit(Q?"success":"error",{action:j,text:Q,trigger:_,clearSelection:function(){_&&_.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(B){return M("action",B)}},{key:"defaultTarget",value:function(B){if(B=M("target",B),B)return document.querySelector(B)}},{key:"defaultText",value:function(B){return M("text",B)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&b(O.prototype,A),D&&b(O,D),P}()},828:function(n){var o;typeof Element>"u"||Element.prototype.matches||((o=Element.prototype).matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector),n.exports=function(s,i){for(;s&&s.nodeType!==9;){if(typeof s.matches=="function"&&s.matches(i))return s;s=s.parentNode}}},438:function(n,o,s){var i=s(828);function a(l,c,u,d,h){var f=function(p,v,y,b){return function(x){x.delegateTarget=i(x.target,v),x.delegateTarget&&b.call(p,x)}}.apply(this,arguments);return l.addEventListener(u,f,h),{destroy:function(){l.removeEventListener(u,f,h)}}}n.exports=function(l,c,u,d,h){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof u=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(f){return a(f,c,u,d,h)}))}},879:function(n,o){o.node=function(s){return s!==void 0&&s instanceof HTMLElement&&s.nodeType===1},o.nodeList=function(s){var i=Object.prototype.toString.call(s);return s!==void 0&&(i==="[object NodeList]"||i==="[object HTMLCollection]")&&"length"in s&&(s.length===0||o.node(s[0]))},o.string=function(s){return typeof s=="string"||s instanceof String},o.fn=function(s){return Object.prototype.toString.call(s)==="[object Function]"}},370:function(n,o,s){var i=s(879),a=s(438);n.exports=function(l,c,u){if(!l&&!c&&!u)throw new Error("Missing required arguments");if(!i.string(c))throw new TypeError("Second argument must be a String");if(!i.fn(u))throw new TypeError("Third argument must be a Function");if(i.node(l))return v=c,y=u,(p=l).addEventListener(v,y),{destroy:function(){p.removeEventListener(v,y)}};if(i.nodeList(l))return d=l,h=c,f=u,Array.prototype.forEach.call(d,function(b){b.addEventListener(h,f)}),{destroy:function(){Array.prototype.forEach.call(d,function(b){b.removeEventListener(h,f)})}};if(i.string(l))return l=l,c=c,u=u,a(document.body,l,c,u);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var d,h,f,p,v,y}},817:function(n){n.exports=function(o){var s,i=o.nodeName==="SELECT"?(o.focus(),o.value):o.nodeName==="INPUT"||o.nodeName==="TEXTAREA"?((s=o.hasAttribute("readonly"))||o.setAttribute("readonly",""),o.select(),o.setSelectionRange(0,o.value.length),s||o.removeAttribute("readonly"),o.value):(o.hasAttribute("contenteditable")&&o.focus(),i=window.getSelection(),(s=document.createRange()).selectNodeContents(o),i.removeAllRanges(),i.addRange(s),i.toString());return i}},279:function(n){function o(){}o.prototype={on:function(s,i,a){var l=this.e||(this.e={});return(l[s]||(l[s]=[])).push({fn:i,ctx:a}),this},once:function(s,i,a){var l=this;function c(){l.off(s,c),i.apply(a,arguments)}return c._=i,this.on(s,c,a)},emit:function(s){for(var i=[].slice.call(arguments,1),a=((this.e||(this.e={}))[s]||[]).slice(),l=0,c=a.length;l<c;l++)a[l].fn.apply(a[l].ctx,i);return this},off:function(s,i){var a=this.e||(this.e={}),l=a[s],c=[];if(l&&i)for(var u=0,d=l.length;u<d;u++)l[u].fn!==i&&l[u].fn._!==i&&c.push(l[u]);return c.length?a[s]=c:delete a[s],this}},n.exports=o,n.exports.TinyEmitter=o}},t={},r.n=function(n){var o=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(o,{a:o}),o},r.d=function(n,o){for(var s in o)r.o(o,s)&&!r.o(n,s)&&Object.defineProperty(n,s,{enumerable:!0,get:o[s]})},r.o=function(n,o){return Object.prototype.hasOwnProperty.call(n,o)},r(686).default;function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}var e,t})});var Lr={},fd=[];function nn(r,e){if(fd.push({name:r,data:e}),typeof Lr[r]>"u")return this;let t=Lr[r];for(let n=0;n<t.length;n++)t[n](e)}function pd(r,e){typeof Lr[r]>"u"&&(Lr[r]=[]),Lr[r].push(e)}function md(r,e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0});r.dispatchEvent(n)}function gd(r){if(!!r.status&&r.status===422&&r.data){let e=Object.values(r.data).flat().join(`
-`);nn("error",e)}}var Ts={emit:nn,emitPublic:md,listen:pd,success:r=>nn("success",r),error:r=>nn("error",r),showValidationErrors:gd};async function vd(r,e={}){return Is(r,{method:"GET",params:e})}async function yd(r,e=null){return on("POST",r,e)}async function bd(r,e=null){return on("PUT",r,e)}async function xd(r,e=null){return on("PATCH",r,e)}async function wd(r,e=null){return on("DELETE",r,e)}async function on(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"),Is(e,n)}async function Is(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 Ed(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 Ed(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 Ds={get:vd,post:yd,put:bd,patch:xd,delete:wd};var oo=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),o=t.getAttribute("value");this.store.set(n,o)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let o=this.getTransText(e);return this.parsePlural(o,t,n)}parsePlural(e,t,n){let o=e.split("|"),s=/^{([0-9]+)}/,i=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let c=l.match(s);if(c!==null&&Number(c[1])===t){a=l.replace(s,"").trim();break}let u=l.match(i);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(i,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,n)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let n=e.match(/:([\S]+)/g);return n===null||n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(e=e.replace(o,t[s]))}),e}},Ls=oo;var uo={};no(uo,{first:()=>kd,firstOnElement:()=>Id,get:()=>Td,init:()=>lo,register:()=>co});function so(r){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=r.split("-");return t[0]+t.slice(1).map(e).join("")}function Fs(r){return r.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var Fr={},Rs={},ao=new WeakMap;function Cd(r,e){let t=Rs[r];if(t===void 0)return;let n;try{n=new t,n.$name=r,n.$el=e;let s=Sd(r,e);n.$refs=s.refs,n.$manyRefs=s.manyRefs,n.$opts=Ad(r,e),n.setup()}catch(s){console.error("Failed to create component",s,r,e)}typeof Fr[r]>"u"&&(Fr[r]=[]),Fr[r].push(n);let o=ao.get(e)||{};o[r]=n,ao.set(e,o)}function Sd(r,e){let t={},n={},o=`${r}@`,s=`[refs*="${o}"]`,i=[...e.querySelectorAll(s)];e.matches(s)&&i.push(e);for(let a of i){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(o)).map(c=>c.replace(o,"")).map(so);for(let c of l)t[c]=a,typeof n[c]>"u"&&(n[c]=[]),n[c].push(a)}return{refs:t,manyRefs:n}}function Ad(r,e){let t={},n=`option:${r}:`;for(let{name:o,value:s}of e.attributes)if(o.startsWith(n)){let i=o.replace(n,"");t[so(i)]=s||""}return t}function lo(r=document){let e=r.querySelectorAll("[component],[components]");for(let t of e){let n=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let o of n)Cd(o,t)}}function co(r){let e=Object.keys(r);for(let t of e)Rs[Fs(t)]=r[t]}function kd(r){return(Fr[r]||[null])[0]}function Td(r){return Fr[r]||[]}function Id(r,e){return(ao.get(r)||{})[e]||null}var Cs={};no(Cs,{AddRemoveRows:()=>ln,AjaxDeleteRow:()=>cn,AjaxForm:()=>un,Attachments:()=>dn,AttachmentsList:()=>hn,AutoSubmit:()=>pn,AutoSuggest:()=>fn,BackToTop:()=>mn,BookSort:()=>Fn,ChapterContents:()=>Pn,CodeEditor:()=>Mn,CodeHighlighter:()=>$n,CodeTextarea:()=>Bn,Collapsible:()=>_n,ConfirmDialog:()=>Nn,CustomCheckbox:()=>Un,DetailsHighlighter:()=>zn,Dropdown:()=>Hn,DropdownSearch:()=>jn,Dropzone:()=>qn,EditorToolbox:()=>Gn,EntityPermissions:()=>Wn,EntitySearch:()=>Yn,EntitySelector:()=>Kn,EntitySelectorPopup:()=>Xn,EventEmitSelect:()=>Zn,ExpandToggle:()=>Qn,GlobalSearch:()=>Jn,HeaderMobileToggle:()=>ei,ImageManager:()=>ti,ImagePicker:()=>ri,ListSortControl:()=>ni,MarkdownEditor:()=>Ai,NewUserPassword:()=>ki,Notification:()=>Ti,OptionalInput:()=>Ii,PageComments:()=>Di,PageDisplay:()=>Li,PageEditor:()=>Fi,PagePicker:()=>Oi,PermissionsTable:()=>Pi,Pointer:()=>Mi,Popup:()=>$i,SettingAppColorPicker:()=>Bi,SettingColorPicker:()=>_i,SettingHomepageControl:()=>Ni,ShelfSort:()=>Ui,ShortcutInput:()=>Hi,Shortcuts:()=>zi,SortableList:()=>ji,SubmitOnChange:()=>Vi,Tabs:()=>qi,TagManager:()=>Gi,TemplateManager:()=>Wi,ToggleSwitch:()=>Yi,TriLayout:()=>Ki,UserSelect:()=>Xi,WebhookEvents:()=>Zi,WysiwygEditor:()=>eo});function ho(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function sn(r,e,t){for(let n of e)r.addEventListener(n,t)}function Ne(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 an(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function Ve(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function Os(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 Rr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Ps(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Kt(r){let e=document.createElement("div");return e.innerHTML=r,window.$components.init(e),e.children[0]}function Ft(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 Or(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 Ms(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function $s(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var V=class{constructor(){ur(this,"$name","");ur(this,"$el",null);ur(this,"$refs",{});ur(this,"$manyRefs",{});ur(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,o=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(o)}};var ln=class extends V{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),Ve(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=$s(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}};var cn=class extends V{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Ne(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var un=class extends V{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}an(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Ne(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var dn=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})})}reloadList(){this.stopEdit(),window.$components.firstOnElement(this.mainTabs,"tabs").show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(t=>{this.list.innerHTML=t.data,window.$components.init(this.list)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),Rr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}};var hn=class extends V{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href=t.href+"?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var po={},fn=class extends V{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()}),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.container.addEventListener("keydown",this.containerKeyDown.bind(this)),Ve(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),Ve(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.toLowerCase(),o=(await this.loadSuggestions(t,e)).filter(s=>t===""||s.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let n={search:e,name:t},o=`${this.url}:${JSON.stringify(n)}`;if(po[o])return po[o];let s=await window.$http.get(this.url,n);return po[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">${Ms(t)}</button></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll("button"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var pn=class extends V{setup(){this.form=this.$el,this.form.submit()}};var mn=class extends V{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,n=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function i(){let a=1-(Date.now()-o)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(i.bind(this))):t.scrollTop=e}requestAnimationFrame(i.bind(this))}};function Bs(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 Pt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bs(Object(t),!0).forEach(function(n){Dd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Bs(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function xn(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xn=function(e){return typeof e}:xn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xn(r)}function Dd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Vt(){return Vt=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},Vt.apply(this,arguments)}function Ld(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 Fd(r,e){if(r==null)return{};var t=Ld(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 Rd="1.15.0";function jt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var qt=jt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Hr=jt(/Edge/i),_s=jt(/firefox/i),Br=jt(/safari/i)&&!jt(/chrome/i)&&!jt(/android/i),Gs=jt(/iP(ad|od|hone)/i),Ws=jt(/chrome/i)&&jt(/android/i),Ys={capture:!1,passive:!1};function $e(r,e,t){r.addEventListener(e,t,!qt&&Ys)}function Fe(r,e,t){r.removeEventListener(e,t,!qt&&Ys)}function An(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 Od(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Rt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&An(r,e):An(r,e))||n&&r===t)return r;if(r===t)break}while(r=Od(r))}return null}var Ns=/\s+/g;function vt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(Ns," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(Ns," ")}}function ve(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 mr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ve(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 Ks(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 Ot(){var r=document.scrollingElement;return r||document.documentElement}function rt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,c,u,d;if(r!==window&&r.parentNode&&r!==Ot()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,d=s.width):(i=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,d=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!qt))do if(o&&o.getBoundingClientRect&&(ve(o,"transform")!=="none"||t&&ve(o,"position")!=="static")){var h=o.getBoundingClientRect();i-=h.top+parseInt(ve(o,"border-top-width")),a-=h.left+parseInt(ve(o,"border-left-width")),l=i+s.height,c=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var f=mr(o||r),p=f&&f.a,v=f&&f.d;f&&(i/=v,a/=p,d/=p,u/=v,l=i+u,c=a+d)}return{top:i,left:a,bottom:l,right:c,width:d,height:u}}}function Us(r,e,t){for(var n=Qt(r,!0),o=rt(r)[e];n;){var s=rt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ot())break;n=Qt(n,!1)}return!1}function gr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ye.ghost&&(n||i[s]!==ye.dragged)&&Rt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function Io(r,e){for(var t=r.lastElementChild;t&&(t===ye.ghost||ve(t,"display")==="none"||e&&!An(t,e));)t=t.previousElementSibling;return t||null}function St(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ye.clone&&(!e||An(r,e))&&t++;return t}function zs(r){var e=0,t=0,n=Ot();if(r)do{var o=mr(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 Pd(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 Qt(r,e){if(!r||!r.getBoundingClientRect)return Ot();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ve(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 Ot();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ot()}function Md(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function mo(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 _r;function Xs(r,e){return function(){if(!_r){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),_r=setTimeout(function(){_r=void 0},e)}}}function $d(){clearTimeout(_r),_r=void 0}function Zs(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Qs(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 bt="Sortable"+new Date().getTime();function Bd(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ve(o,"display")==="none"||o===ye.ghost)){r.push({target:o,rect:rt(o)});var s=Pt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=mr(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(Pd(r,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,i=0;r.forEach(function(a){var l=0,c=a.target,u=c.fromRect,d=rt(c),h=c.prevFromRect,f=c.prevToRect,p=a.rect,v=mr(c,!0);v&&(d.top-=v.f,d.left-=v.e),c.toRect=d,c.thisAnimationDuration&&mo(h,d)&&!mo(u,d)&&(p.top-d.top)/(p.left-d.left)===(u.top-d.top)/(u.left-d.left)&&(l=Nd(p,h,f,o.options)),mo(d,u)||(c.prevFromRect=u,c.prevToRect=d,l||(l=o.options.animation),o.animate(c,p,d,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof n=="function"&&n()},i):typeof n=="function"&&n(),r=[]},animate:function(n,o,s,i){if(i){ve(n,"transition",""),ve(n,"transform","");var a=mr(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);n.animatingX=!!u,n.animatingY=!!d,ve(n,"transform","translate3d("+u+"px,"+d+"px,0)"),this.forRepaintDummy=_d(n),ve(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ve(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ve(n,"transition",""),ve(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function _d(r){return r.offsetWidth}function Nd(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 dr=[],go={initializeByDefault:!0},jr={mount:function(e){for(var t in go)go.hasOwnProperty(t)&&!(t in e)&&(e[t]=go[t]);dr.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),dr.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";dr.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Pt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Pt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){dr.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,Vt(n,c.defaults)}});for(var s in e.options)if(!!e.options.hasOwnProperty(s)){var i=this.modifyOption(e,s,e.options[s]);typeof i<"u"&&(e.options[s]=i)}},getEventProperties:function(e,t){var n={};return dr.forEach(function(o){typeof o.eventProperties=="function"&&Vt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return dr.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function Ud(r){var e=r.sortable,t=r.rootEl,n=r.name,o=r.targetEl,s=r.cloneEl,i=r.toEl,a=r.fromEl,l=r.oldIndex,c=r.newIndex,u=r.oldDraggableIndex,d=r.newDraggableIndex,h=r.originalEvent,f=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[bt],!!e){var v,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!qt&&!Hr?v=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(v=document.createEvent("Event"),v.initEvent(n,!0,!0)),v.to=i||t,v.from=a||t,v.item=o||t,v.clone=s,v.oldIndex=l,v.newIndex=c,v.oldDraggableIndex=u,v.newDraggableIndex=d,v.originalEvent=h,v.pullMode=f?f.lastPutMode:void 0;var x=Pt(Pt({},p),jr.getEventProperties(n,e));for(var I in x)v[I]=x[I];t&&t.dispatchEvent(v),y[b]&&y[b].call(e,v)}}var zd=["evt"],pt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Fd(n,zd);jr.pluginEvent.bind(ye)(e,t,Pt({dragEl:te,parentEl:Qe,ghostEl:Ee,rootEl:Ge,nextEl:nr,lastDownEl:wn,cloneEl:Ke,cloneHidden:Zt,dragStarted:Pr,putSortable:ot,activeSortable:ye.active,originalEvent:o,oldIndex:pr,oldDraggableIndex:Nr,newIndex:yt,newDraggableIndex:Xt,hideGhostForTarget:ra,unhideGhostForTarget:na,cloneNowHidden:function(){Zt=!0},cloneNowShown:function(){Zt=!1},dispatchSortableEvent:function(a){dt({sortable:t,name:a,originalEvent:o})}},s))};function dt(r){Ud(Pt({putSortable:ot,cloneEl:Ke,targetEl:te,rootEl:Ge,oldIndex:pr,oldDraggableIndex:Nr,newIndex:yt,newDraggableIndex:Xt},r))}var te,Qe,Ee,Ge,nr,wn,Ke,Zt,pr,yt,Nr,Xt,gn,ot,fr=!1,kn=!1,Tn=[],tr,Tt,vo,yo,Hs,js,Pr,hr,Ur,zr=!1,vn=!1,En,ct,bo=[],So=!1,In=[],Ln=typeof document<"u",yn=Gs,Vs=Hr||qt?"cssFloat":"float",Hd=Ln&&!Ws&&!Gs&&"draggable"in document.createElement("div"),Js=function(){if(!!Ln){if(qt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),ea=function(e,t){var n=ve(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=gr(e,0,t),i=gr(e,1,t),a=s&&ve(s),l=i&&ve(i),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+rt(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+rt(i).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&n[Vs]==="none"||i&&n[Vs]==="none"&&c+u>o)?"vertical":"horizontal"},jd=function(e,t,n){var o=n?e.left:e.top,s=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,c=n?t.width:t.height;return o===a||s===l||o+i/2===a+c/2},Vd=function(e,t){var n;return Tn.some(function(o){var s=o[bt].options.emptyInsertThreshold;if(!(!s||Io(o))){var i=rt(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},ta=function(e){function t(s,i){return function(a,l,c,u){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||d))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,c,u),i)(a,l,c,u);var h=(i?a:l).options.group.name;return s===!0||typeof s=="string"&&s===h||s.join&&s.indexOf(h)>-1}}var n={},o=e.group;(!o||xn(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},ra=function(){!Js&&Ee&&ve(Ee,"display","none")},na=function(){!Js&&Ee&&ve(Ee,"display","")};Ln&&!Ws&&document.addEventListener("click",function(r){if(kn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),kn=!1,!1},!0);var rr=function(e){if(te){e=e.touches?e.touches[0]:e;var t=Vd(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[bt]._onDragOver(n)}}},qd=function(e){te&&te.parentNode[bt]._isOutsideThisEl(e.target)};function ye(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=Vt({},e),r[bt]=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 ea(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(i,a){i.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ye.supportPointer!==!1&&"PointerEvent"in window&&!Br,emptyInsertThreshold:5};jr.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);ta(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:Hd,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?$e(r,"pointerdown",this._onTapStart):($e(r,"mousedown",this._onTapStart),$e(r,"touchstart",this._onTapStart)),this.nativeDraggable&&($e(r,"dragover",this),$e(r,"dragenter",this)),Tn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Vt(this,Bd())}ye.prototype={constructor:ye,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(hr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,te):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=o.filter;if(Jd(n),!te&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Br&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Rt(l,o.draggable,n,!1),!(l&&l.animated)&&wn!==l)){if(pr=St(l),Nr=St(l,o.draggable),typeof u=="function"){if(u.call(this,e,l,this)){dt({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),pt("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(d){if(d=Rt(c,d.trim(),n,!1),d)return dt({sortable:t,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),pt("filter",t,{evt:e}),!0}),u)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Rt(c,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,i=o.options,a=s.ownerDocument,l;if(n&&!te&&n.parentNode===s){var c=rt(n);if(Ge=s,te=n,Qe=te.parentNode,nr=te.nextSibling,wn=n,gn=i.group,ye.dragged=te,tr={target:te,clientX:(t||e).clientX,clientY:(t||e).clientY},Hs=tr.clientX-c.left,js=tr.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,te.style["will-change"]="all",l=function(){if(pt("delayEnded",o,{evt:e}),ye.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!_s&&o.nativeDraggable&&(te.draggable=!0),o._triggerDragStart(e,t),dt({sortable:o,name:"choose",originalEvent:e}),vt(te,i.chosenClass,!0)},i.ignore.split(",").forEach(function(u){Ks(te,u.trim(),xo)}),$e(a,"dragover",rr),$e(a,"mousemove",rr),$e(a,"touchmove",rr),$e(a,"mouseup",o._onDrop),$e(a,"touchend",o._onDrop),$e(a,"touchcancel",o._onDrop),_s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,te.draggable=!0),pt("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Hr||qt))){if(ye.eventCanceled){this._onDrop();return}$e(a,"mouseup",o._disableDelayedDrag),$e(a,"touchend",o._disableDelayedDrag),$e(a,"touchcancel",o._disableDelayedDrag),$e(a,"mousemove",o._delayedDragTouchMoveHandler),$e(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&$e(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,i.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){te&&xo(te),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Fe(e,"mouseup",this._disableDelayedDrag),Fe(e,"touchend",this._disableDelayedDrag),Fe(e,"touchcancel",this._disableDelayedDrag),Fe(e,"mousemove",this._delayedDragTouchMoveHandler),Fe(e,"touchmove",this._delayedDragTouchMoveHandler),Fe(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?$e(document,"pointermove",this._onTouchMove):t?$e(document,"touchmove",this._onTouchMove):$e(document,"mousemove",this._onTouchMove):($e(te,"dragend",this),$e(Ge,"dragstart",this._onDragStart));try{document.selection?Cn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(fr=!1,Ge&&te){pt("dragStarted",this,{evt:t}),this.nativeDraggable&&$e(document,"dragover",qd);var n=this.options;!e&&vt(te,n.dragClass,!1),vt(te,n.ghostClass,!0),ye.active=this,e&&this._appendGhost(),dt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Tt){this._lastX=Tt.clientX,this._lastY=Tt.clientY,ra();for(var e=document.elementFromPoint(Tt.clientX,Tt.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Tt.clientX,Tt.clientY),e!==t);)t=e;if(te.parentNode[bt]._isOutsideThisEl(e),t)do{if(t[bt]){var n=void 0;if(n=t[bt]._onDragOver({clientX:Tt.clientX,clientY:Tt.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);na()}},_onTouchMove:function(e){if(tr){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=Ee&&mr(Ee,!0),a=Ee&&i&&i.a,l=Ee&&i&&i.d,c=yn&&ct&&zs(ct),u=(s.clientX-tr.clientX+o.x)/(a||1)+(c?c[0]-bo[0]:0)/(a||1),d=(s.clientY-tr.clientY+o.y)/(l||1)+(c?c[1]-bo[1]:0)/(l||1);if(!ye.active&&!fr){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(Ee){i?(i.e+=u-(vo||0),i.f+=d-(yo||0)):i={a:1,b:0,c:0,d:1,e:u,f:d};var h="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ve(Ee,"webkitTransform",h),ve(Ee,"mozTransform",h),ve(Ee,"msTransform",h),ve(Ee,"transform",h),vo=u,yo=d,Tt=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!Ee){var e=this.options.fallbackOnBody?document.body:Ge,t=rt(te,!0,yn,!0,e),n=this.options;if(yn){for(ct=e;ve(ct,"position")==="static"&&ve(ct,"transform")==="none"&&ct!==document;)ct=ct.parentNode;ct!==document.body&&ct!==document.documentElement?(ct===document&&(ct=Ot()),t.top+=ct.scrollTop,t.left+=ct.scrollLeft):ct=Ot(),bo=zs(ct)}Ee=te.cloneNode(!0),vt(Ee,n.ghostClass,!1),vt(Ee,n.fallbackClass,!0),vt(Ee,n.dragClass,!0),ve(Ee,"transition",""),ve(Ee,"transform",""),ve(Ee,"box-sizing","border-box"),ve(Ee,"margin",0),ve(Ee,"top",t.top),ve(Ee,"left",t.left),ve(Ee,"width",t.width),ve(Ee,"height",t.height),ve(Ee,"opacity","0.8"),ve(Ee,"position",yn?"absolute":"fixed"),ve(Ee,"zIndex","100000"),ve(Ee,"pointerEvents","none"),ye.ghost=Ee,e.appendChild(Ee),ve(Ee,"transform-origin",Hs/parseInt(Ee.style.width)*100+"% "+js/parseInt(Ee.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(pt("dragStart",this,{evt:e}),ye.eventCanceled){this._onDrop();return}pt("setupClone",this),ye.eventCanceled||(Ke=Qs(te),Ke.removeAttribute("id"),Ke.draggable=!1,Ke.style["will-change"]="",this._hideClone(),vt(Ke,this.options.chosenClass,!1),ye.clone=Ke),n.cloneId=Cn(function(){pt("clone",n),!ye.eventCanceled&&(n.options.removeCloneOnHide||Ge.insertBefore(Ke,te),n._hideClone(),dt({sortable:n,name:"clone"}))}),!t&&vt(te,s.dragClass,!0),t?(kn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Fe(document,"mouseup",n._onDrop),Fe(document,"touchend",n._onDrop),Fe(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,te)),$e(document,"drop",n),ve(te,"transform","translateZ(0)")),fr=!0,n._dragStartId=Cn(n._dragStarted.bind(n,t,e)),$e(document,"selectstart",n),Pr=!0,Br&&ve(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,c=ye.active,u=gn===l,d=a.sort,h=ot||c,f,p=this,v=!1;if(So)return;function y(ie,xe){pt(ie,p,Pt({evt:e,isOwner:u,axis:f?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:d,fromSortable:h,target:n,completed:x,onMove:function(we,Re){return bn(Ge,t,te,o,we,rt(we),e,Re)},changed:I},xe))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ie){return y("dragOverCompleted",{insertion:ie}),ie&&(u?c._hideClone():c._showClone(p),p!==h&&(vt(te,ot?ot.options.ghostClass:c.options.ghostClass,!1),vt(te,a.ghostClass,!0)),ot!==p&&p!==ye.active?ot=p:p===ye.active&&ot&&(ot=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===te&&!te.animated||n===t&&!n.animated)&&(hr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(te.parentNode[bt]._isOutsideThisEl(e.target),!ie&&rr(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),v=!0}function I(){yt=St(te),Xt=St(te,a.draggable),dt({sortable:p,name:"change",toEl:t,newIndex:yt,newDraggableIndex:Xt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Rt(n,a.draggable,t,!0),y("dragOver"),ye.eventCanceled)return v;if(te.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(kn=!1,c&&!a.disabled&&(u?d||(i=Qe!==Ge):ot===this||(this.lastPutMode=gn.checkPull(this,c,te,e))&&l.checkPut(this,c,te,e))){if(f=this._getDirection(e,n)==="vertical",o=rt(te),y("dragOverValid"),ye.eventCanceled)return v;if(i)return Qe=Ge,b(),this._hideClone(),y("revert"),ye.eventCanceled||(nr?Ge.insertBefore(te,nr):Ge.appendChild(te)),x(!0);var C=Io(t,a.draggable);if(!C||Kd(e,f,this)&&!C.animated){if(C===te)return x(!1);if(C&&t===e.target&&(n=C),n&&(s=rt(n)),bn(Ge,t,te,o,n,s,e,!!n)!==!1)return b(),C&&C.nextSibling?t.insertBefore(te,C.nextSibling):t.appendChild(te),Qe=t,I(),x(!0)}else if(C&&Yd(e,f,this)){var M=gr(t,0,a,!0);if(M===te)return x(!1);if(n=M,s=rt(n),bn(Ge,t,te,o,n,s,e,!1)!==!1)return b(),t.insertBefore(te,M),Qe=t,I(),x(!0)}else if(n.parentNode===t){s=rt(n);var S=0,O,A=te.parentNode!==t,D=!jd(te.animated&&te.toRect||o,n.animated&&n.toRect||s,f),T=f?"top":"left",P=Us(n,"top","top")||Us(te,"top","top"),B=P?P.scrollTop:void 0;hr!==n&&(O=s[T],zr=!1,vn=!D&&a.invertSwap||A),S=Xd(e,n,s,f,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vn,hr===n);var _;if(S!==0){var j=St(te);do j-=S,_=Qe.children[j];while(_&&(ve(_,"display")==="none"||_===Ee))}if(S===0||_===n)return x(!1);hr=n,Ur=S;var Q=n.nextElementSibling,Y=!1;Y=S===1;var re=bn(Ge,t,te,o,n,s,e,Y);if(re!==!1)return(re===1||re===-1)&&(Y=re===1),So=!0,setTimeout(Wd,30),b(),Y&&!Q?t.appendChild(te):n.parentNode.insertBefore(te,Y?Q:n),P&&Zs(P,0,B-P.scrollTop),Qe=te.parentNode,O!==void 0&&!vn&&(En=Math.abs(O-rt(n)[T])),I(),x(!0)}if(t.contains(te))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Fe(document,"mousemove",this._onTouchMove),Fe(document,"touchmove",this._onTouchMove),Fe(document,"pointermove",this._onTouchMove),Fe(document,"dragover",rr),Fe(document,"mousemove",rr),Fe(document,"touchmove",rr)},_offUpEvents:function(){var e=this.el.ownerDocument;Fe(e,"mouseup",this._onDrop),Fe(e,"touchend",this._onDrop),Fe(e,"pointerup",this._onDrop),Fe(e,"touchcancel",this._onDrop),Fe(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(yt=St(te),Xt=St(te,n.draggable),pt("drop",this,{evt:e}),Qe=te&&te.parentNode,yt=St(te),Xt=St(te,n.draggable),ye.eventCanceled){this._nulling();return}fr=!1,vn=!1,zr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ao(this.cloneId),Ao(this._dragStartId),this.nativeDraggable&&(Fe(document,"drop",this),Fe(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Br&&ve(document.body,"user-select",""),ve(te,"transform",""),e&&(Pr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),Ee&&Ee.parentNode&&Ee.parentNode.removeChild(Ee),(Ge===Qe||ot&&ot.lastPutMode!=="clone")&&Ke&&Ke.parentNode&&Ke.parentNode.removeChild(Ke),te&&(this.nativeDraggable&&Fe(te,"dragend",this),xo(te),te.style["will-change"]="",Pr&&!fr&&vt(te,ot?ot.options.ghostClass:this.options.ghostClass,!1),vt(te,this.options.chosenClass,!1),dt({sortable:this,name:"unchoose",toEl:Qe,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ge!==Qe?(yt>=0&&(dt({rootEl:Qe,name:"add",toEl:Qe,fromEl:Ge,originalEvent:e}),dt({sortable:this,name:"remove",toEl:Qe,originalEvent:e}),dt({rootEl:Qe,name:"sort",toEl:Qe,fromEl:Ge,originalEvent:e}),dt({sortable:this,name:"sort",toEl:Qe,originalEvent:e})),ot&&ot.save()):yt!==pr&&yt>=0&&(dt({sortable:this,name:"update",toEl:Qe,originalEvent:e}),dt({sortable:this,name:"sort",toEl:Qe,originalEvent:e})),ye.active&&((yt==null||yt===-1)&&(yt=pr,Xt=Nr),dt({sortable:this,name:"end",toEl:Qe,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){pt("nulling",this),Ge=te=Qe=Ee=nr=Ke=wn=Zt=tr=Tt=Pr=yt=Xt=pr=Nr=hr=Ur=ot=gn=ye.dragged=ye.ghost=ye.clone=ye.active=null,In.forEach(function(e){e.checked=!0}),In.length=vo=yo=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":te&&(this._onDragOver(e),Gd(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],Rt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||Qd(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Rt(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 Rt(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=jr.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&ta(n)},destroy:function(){pt("destroy",this);var e=this.el;e[bt]=null,Fe(e,"mousedown",this._onTapStart),Fe(e,"touchstart",this._onTapStart),Fe(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Fe(e,"dragover",this),Fe(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Tn.splice(Tn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Zt){if(pt("hideClone",this),ye.eventCanceled)return;ve(Ke,"display","none"),this.options.removeCloneOnHide&&Ke.parentNode&&Ke.parentNode.removeChild(Ke),Zt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Zt){if(pt("showClone",this),ye.eventCanceled)return;te.parentNode==Ge&&!this.options.group.revertClone?Ge.insertBefore(Ke,te):nr?Ge.insertBefore(Ke,nr):Ge.appendChild(Ke),this.options.group.revertClone&&this.animate(te,Ke),ve(Ke,"display",""),Zt=!1}}};function Gd(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function bn(r,e,t,n,o,s,i,a){var l,c=r[bt],u=c.options.onMove,d;return window.CustomEvent&&!qt&&!Hr?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||rt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),u&&(d=u.call(c,l,i)),d}function xo(r){r.draggable=!1}function Wd(){So=!1}function Yd(r,e,t){var n=rt(gr(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 Kd(r,e,t){var n=rt(Io(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 Xd(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,c=n?t.height:t.width,u=n?t.top:t.left,d=n?t.bottom:t.right,h=!1;if(!i){if(a&&En<c*o){if(!zr&&(Ur===1?l>u+c*s/2:l<d-c*s/2)&&(zr=!0),zr)h=!0;else if(Ur===1?l<u+En:l>d-En)return-Ur}else if(l>u+c*(1-o)/2&&l<d-c*(1-o)/2)return Zd(e)}return h=h||i,h&&(l<u+c*s/2||l>d-c*s/2)?l>u+c/2?1:-1:0}function Zd(r){return St(te)<St(r)?1:-1}function Qd(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 Jd(r){In.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&In.push(n)}}function Cn(r){return setTimeout(r,0)}function Ao(r){return clearTimeout(r)}Ln&&$e(document,"touchmove",function(r){(ye.active||fr)&&r.cancelable&&r.preventDefault()});ye.utils={on:$e,off:Fe,css:ve,find:Ks,is:function(e,t){return!!Rt(e,t,e,!1)},extend:Md,throttle:Xs,closest:Rt,toggleClass:vt,clone:Qs,index:St,nextTick:Cn,cancelNextTick:Ao,detectDirection:ea,getChild:gr};ye.get=function(r){return r[bt]};ye.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(ye.utils=Pt(Pt({},ye.utils),n.utils)),jr.mount(n)})};ye.create=function(r,e){return new ye(r,e)};ye.version=Rd;var et=[],Mr,ko,To=!1,wo,Eo,Dn,$r;function eh(){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?$e(document,"dragover",this._handleAutoScroll):this.options.supportPointer?$e(document,"pointermove",this._handleFallbackAutoScroll):n.touches?$e(document,"touchmove",this._handleFallbackAutoScroll):$e(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Fe(document,"dragover",this._handleAutoScroll):(Fe(document,"pointermove",this._handleFallbackAutoScroll),Fe(document,"touchmove",this._handleFallbackAutoScroll),Fe(document,"mousemove",this._handleFallbackAutoScroll)),qs(),Sn(),$d()},nulling:function(){Dn=ko=Mr=To=$r=wo=Eo=null,et.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(Dn=t,n||this.options.forceAutoScrollFallback||Hr||qt||Br){Co(t,this.options,a,n);var l=Qt(a,!0);To&&(!$r||s!==wo||i!==Eo)&&($r&&qs(),$r=setInterval(function(){var c=Qt(document.elementFromPoint(s,i),!0);c!==l&&(l=c,Sn()),Co(t,o.options,c,n)},10),wo=s,Eo=i)}else{if(!this.options.bubbleScroll||Qt(a,!0)===Ot()){Sn();return}Co(t,this.options,Qt(a,!1),!1)}}},Vt(r,{pluginName:"scroll",initializeByDefault:!0})}function Sn(){et.forEach(function(r){clearInterval(r.pid)}),et=[]}function qs(){clearInterval($r)}var Co=Xs(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=Ot(),c=!1,u;ko!==t&&(ko=t,Sn(),Mr=e.scroll,u=e.scrollFn,Mr===!0&&(Mr=Qt(t,!0)));var d=0,h=Mr;do{var f=h,p=rt(f),v=p.top,y=p.bottom,b=p.left,x=p.right,I=p.width,C=p.height,M=void 0,S=void 0,O=f.scrollWidth,A=f.scrollHeight,D=ve(f),T=f.scrollLeft,P=f.scrollTop;f===l?(M=I<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=I<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var B=M&&(Math.abs(x-o)<=i&&T+I<O)-(Math.abs(b-o)<=i&&!!T),_=S&&(Math.abs(y-s)<=i&&P+C<A)-(Math.abs(v-s)<=i&&!!P);if(!et[d])for(var j=0;j<=d;j++)et[j]||(et[j]={});(et[d].vx!=B||et[d].vy!=_||et[d].el!==f)&&(et[d].el=f,et[d].vx=B,et[d].vy=_,clearInterval(et[d].pid),(B!=0||_!=0)&&(c=!0,et[d].pid=setInterval(function(){n&&this.layer===0&&ye.active._onTouchMove(Dn);var Q=et[this.layer].vy?et[this.layer].vy*a:0,Y=et[this.layer].vx?et[this.layer].vx*a:0;typeof u=="function"&&u.call(ye.dragged.parentNode[bt],Y,Q,r,Dn,et[this.layer].el)!=="continue"||Zs(et[this.layer].el,Y,Q)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&h!==l&&(h=Qt(h,!1)));To=c}},30),ia=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,i=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(!!t){var c=n||s;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,d=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(d)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Do(){}Do.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=gr(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:ia};Vt(Do,{pluginName:"revertOnSpill"});function Lo(){}Lo.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:ia};Vt(Lo,{pluginName:"removeOnSpill"});ye.mount(new eh);ye.mount(Lo,Do);var vr=ye;var oa={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}},Fn=class extends V{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input;let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),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=oa[a];t&&n.includes(a)&&(l=function(c,u){return 0-oa[a](c,u)});for(let c of i)Array.from(c.children).filter(d=>d.matches("li")).sort(l).forEach(d=>{c.appendChild(d)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=Kt(o.data);this.sortContainer.append(s),this.setupBookSortable(s)})}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 vr(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.container.querySelectorAll(".sort-list");for(let n of t){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(i=>i.matches('[data-type="page"], [data-type="chapter"]'));for(let i=0;i<s.length;i++)this.addBookChildToMap(s[i],i,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),i=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:i,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)o.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:n})}};var Rn=new WeakMap;function sa(r,e=400,t=null){qr(r),r.style.display="block",Vr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function On(r,e=400,t=null){qr(r),Vr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function yr(r,e=400){qr(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"]};Vr(r,i,e,()=>{r.style.display="none"})}function br(r,e=400){qr(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]};Vr(r,i,e)}function aa(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{qr(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,c]};Vr(r,u,e)}}function Vr(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),Rn.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),Rn.set(r,s)},15)}function qr(r){Rn.has(r)&&Rn.get(r)()}var Pn=class extends V{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),br(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),yr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Mn=class extends V{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),Ne(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),an(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Ne(this.saveButton,e=>this.save()),Ve(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let t=e.dataset.lang,n=this.favourites.has(t);e.setAttribute("data-favourite",n?"true":"false"),Ve(e.parentElement,".lang-option-favorite-toggle","click",()=>{n=!n,n?this.favourites.add(t):this.favourites.delete(t),e.setAttribute("data-favourite",n?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:t,active:n}),this.sortLanguageList(),n&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((t,n)=>{let o=t.dataset.favourite==="true",s=n.dataset.favourite==="true";return o&&!s?-1:s&&!o||t.dataset.lang>n.dataset.lang?1:-1}).map(t=>t.parentElement);for(let t of e)this.languageOptionsContainer.append(t)}save(){this.callback&&this.callback(this.editor.getValue(),this.languageInput.value),this.hide()}open(e,t,n){this.languageInput.value=t,this.callback=n,this.show().then(()=>this.languageInputChange(t)).then(()=>window.importVersioned("code")).then(o=>o.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase();for(let n of this.languageButtons){let o=n.dataset.lang.toLowerCase().trim(),s=t===o;n.classList.toggle("active",s),s&&n.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}};var $n=class extends V{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var Bn=class extends V{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var _n=class extends V{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),br(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),yr(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var Nn=class extends V{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Ne(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var Un=class extends V{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var zn=class extends V{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var Gr,Fo,Wr,Ro,xr=class{constructor(e,t=null,n=null){io(this,Gr);io(this,Wr);this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",Dr(this,Gr,Fo).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",Dr(this,Gr,Fo).bind(this))}focusNext(){let e=Dr(this,Wr,Ro).call(this),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=Dr(this,Wr,Ro).call(this),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}};Gr=new WeakSet,Fo=function(e){e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e)},Wr=new WeakSet,Ro=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"]),input:not([type=hidden])';for(let n of this.containers)e.push(...n.querySelectorAll(t));return e};var Hn=class extends V{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,s=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,n=s?window.innerHeight-t.top-o/2:t.top),s?(this.menu.style.top="initial",this.menu.style.bottom=`${n}px`):(this.menu.style.top=`${n}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let i=this.menu.querySelector("input");i!==null&&i.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let e=new xr(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Ne(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var jn=class extends V{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Ft(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=aa(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var ca=rn(la());var qn=class extends V{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new ca.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),On(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let o=s=>{let i=e.previewElement.querySelector("[data-dz-errormessage]");i.textContent=s};n&&n.status===413?o(this.uploadLimitMessage):t.file&&o(t.file)}removeAll(){this.dz.removeAllFiles(!0)}};var Gn=class extends V{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let n=t.dataset.tab;this.setActiveTab(n,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n of this.buttons)n.classList.remove("active"),n.dataset.tab===e&&n.classList.add("active");for(let n of this.contentElements)n.style.display="none",n.dataset.tabContent===e&&(n.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Wn=class extends V{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",e=>{let t=e.target.checked,n=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of n)o.disabled=t,o.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",e=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let n=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),o=Kt(n.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),n=e.dataset.roleId,o=e.dataset.roleName,s=document.createElement("option");s.value=n,s.textContent=o,this.roleSelect.append(s),t.remove()}};var Yn=class extends V{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),Ne(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var Kn=class extends V{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.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())}),Ve(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(n=>{this.resultsContainer.innerHTML=n.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),n=e.getAttribute("data-entity-type"),o=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${o}`:"";let i=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:i};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Xn=class extends V{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e){this.callback=e,this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Zn=class extends V{setup(){this.container=this.$el,this.name=this.$opts.name,Ne(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Qn=class extends V{setup(e){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(e){br(e,200)}close(e){yr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var Jn=class extends V{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let e=Ft(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let t=this.input.value;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new xr(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let n=Kt(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(n),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var ei=class extends V{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var ti=class extends V{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.formContainer=this.$refs.formContainer,this.dropzoneContainer=this.$refs.dropzoneContainer,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){Ne(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()}),Ne(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())}),Ve(this.listContainer,".load-more","click",async e=>{Rr(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),Ne(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),Ve(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),Ps(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(){Rr(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),o?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,window.$components.init(this.formContainer)}};var ri=class extends V{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var ni=class extends V{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var wu=rn(mu()),Eu=rn(xu()),yi=class{constructor(){this.renderer=new wu.default({html:!0}),this.renderer.use(Eu.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Sp(r,e){return document.createElement(r,e)}function Ap(r,e,t){return document.createElementNS(r,e,t)}function kp(){return document.createDocumentFragment()}function Tp(r){return document.createTextNode(r)}function Ip(r){return document.createComment(r)}function Dp(r,e,t){r.insertBefore(e,t)}function Lp(r,e){r.removeChild(e)}function Fp(r,e){r.appendChild(e)}function Rp(r){return r.parentNode}function Op(r){return r.nextSibling}function Pp(r){return r.tagName}function Mp(r,e){r.textContent=e}function $p(r){return r.textContent}function Bp(r){return r.nodeType===1}function _p(r){return r.nodeType===3}function Np(r){return r.nodeType===8}function Up(r){return r.nodeType===11}var bi={createElement:Sp,createElementNS:Ap,createTextNode:Tp,createDocumentFragment:kp,createComment:Ip,insertBefore:Dp,removeChild:Lp,appendChild:Fp,parentNode:Rp,nextSibling:Op,tagName:Pp,setTextContent:Mp,getTextContent:$p,isElement:Bp,isText:_p,isComment:Np,isDocumentFragment:Up};function Gt(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 Cu=Array.isArray;function Su(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function us(r){return r===void 0}function mt(r){return r!==void 0}var ds=Gt("",{},[],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 Hp(){throw new Error("The document fragment is not supported on this platform.")}function jp(r,e){return r.isElement(e)}function Vp(r,e){return r.isDocumentFragment(e)}function qp(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 Gp=["create","update","remove","destroy","pre","post"];function hs(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:bi;for(let p of Gp)for(let v of r){let y=v[p];y!==void 0&&n[p].push(y)}function s(p){let v=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return Gt(o.tagName(p).toLowerCase()+v+b,{},[],void 0,p)}function i(p){return Gt(void 0,{},[],void 0,p)}function a(p,v){return function(){if(--v===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,v){var y,b,x,I;let C,M=p.data;if(M!==void 0){let A=(y=M.hook)===null||y===void 0?void 0:y.init;mt(A)&&(A(p),M=p.data)}let S=p.children,O=p.sel;if(O==="!")us(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(O!==void 0){let A=O.indexOf("#"),D=O.indexOf(".",A),T=A>0?A:O.length,P=D>0?D:O.length,B=A!==-1||D!==-1?O.slice(0,Math.min(T,P)):O,_=p.elm=mt(M)&&mt(C=M.ns)?o.createElementNS(C,B,M):o.createElement(B,M);for(T<P&&_.setAttribute("id",O.slice(T+1,P)),D>0&&_.setAttribute("class",O.slice(P+1).replace(/\./g," ")),C=0;C<n.create.length;++C)n.create[C](ds,p);if(Cu(S))for(C=0;C<S.length;++C){let Q=S[C];Q!=null&&o.appendChild(_,l(Q,v))}else Su(p.text)&&o.appendChild(_,o.createTextNode(p.text));let j=p.data.hook;mt(j)&&((b=j.create)===null||b===void 0||b.call(j,ds,p),j.insert&&v.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let A=p.children;for(p.elm=((I=o.createDocumentFragment)!==null&&I!==void 0?I:Hp)(),C=0;C<n.create.length;++C)n.create[C](ds,p);for(C=0;C<A.length;++C){let D=A[C];D!=null&&o.appendChild(p.elm,l(D,v))}}else p.elm=o.createTextNode(p.text);return p.elm}function c(p,v,y,b,x,I){for(;b<=x;++b){let C=y[b];C!=null&&o.insertBefore(p,l(C,I),v)}}function u(p){var v,y;let b=p.data;if(b!==void 0){(y=(v=b?.hook)===null||v===void 0?void 0:v.destroy)===null||y===void 0||y.call(v,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let I=p.children[x];I!=null&&typeof I!="string"&&u(I)}}}function d(p,v,y,b){for(var x,I;y<=b;++y){let C,M,S=v[y];if(S!=null)if(mt(S.sel)){u(S),C=n.remove.length+1,M=a(S.elm,C);for(let A=0;A<n.remove.length;++A)n.remove[A](S,M);let O=(I=(x=S?.data)===null||x===void 0?void 0:x.hook)===null||I===void 0?void 0:I.remove;mt(O)?O(S,M):M()}else o.removeChild(p,S.elm)}}function h(p,v,y,b){let x=0,I=0,C=v.length-1,M=v[0],S=v[C],O=y.length-1,A=y[0],D=y[O],T,P,B,_;for(;x<=C&&I<=O;)M==null?M=v[++x]:S==null?S=v[--C]:A==null?A=y[++I]:D==null?D=y[--O]:Qr(M,A)?(f(M,A,b),M=v[++x],A=y[++I]):Qr(S,D)?(f(S,D,b),S=v[--C],D=y[--O]):Qr(M,D)?(f(M,D,b),o.insertBefore(p,M.elm,o.nextSibling(S.elm)),M=v[++x],D=y[--O]):Qr(S,A)?(f(S,A,b),o.insertBefore(p,S.elm,M.elm),S=v[--C],A=y[++I]):(T===void 0&&(T=qp(v,x,C)),P=T[A.key],us(P)?o.insertBefore(p,l(A,b),M.elm):(B=v[P],B.sel!==A.sel?o.insertBefore(p,l(A,b),M.elm):(f(B,A,b),v[P]=void 0,o.insertBefore(p,B.elm,M.elm))),A=y[++I]);I<=O&&(_=y[O+1]==null?null:y[O+1].elm,c(p,_,y,I,O,b)),x<=C&&d(p,v,x,C)}function f(p,v,y){var b,x,I,C,M,S,O,A;let D=(b=v.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,v);let T=v.elm=p.elm,P=p.children,B=v.children;if(p!==v){if(v.data!==void 0||mt(v.text)&&v.text!==p.text){(I=v.data)!==null&&I!==void 0||(v.data={}),(C=p.data)!==null&&C!==void 0||(p.data={});for(let _=0;_<n.update.length;++_)n.update[_](p,v);(O=(S=(M=v.data)===null||M===void 0?void 0:M.hook)===null||S===void 0?void 0:S.update)===null||O===void 0||O.call(S,p,v)}us(v.text)?mt(P)&&mt(B)?P!==B&&h(T,P,B,y):mt(B)?(mt(p.text)&&o.setTextContent(T,""),c(T,null,B,0,B.length-1,y)):mt(P)?d(T,P,0,P.length-1):mt(p.text)&&o.setTextContent(T,""):p.text!==v.text&&(mt(P)&&d(T,P,0,P.length-1),o.setTextContent(T,v.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,v)}}return function(v,y){let b,x,I,C=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(jp(o,v)?v=s(v):Vp(o,v)&&(v=i(v)),Qr(v,y)?f(v,y,C):(x=v.elm,I=o.parentNode(x),l(y,C),I!==null&&(o.insertBefore(I,y.elm,o.nextSibling(x)),d(I,[v],0,0))),b=0;b<C.length;++b)C[b].data.hook.insert(C[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function fs(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&fs(s,o.children,o.sel)}}function Jr(r,e){let t=e!==void 0?e:bi,n;if(t.isElement(r)){let o=r.id?"#"+r.id:"",s=r.getAttribute("class"),i=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+o+i,l={},c={},u={},d=[],h,f,p,v=r.attributes,y=r.childNodes;for(f=0,p=v.length;f<p;f++)h=v[f].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?c[h.slice(5)]=v[f].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=v[f].nodeValue);for(f=0,p=y.length;f<p;f++)d.push(Jr(y[f],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.datasets=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&fs(u,d,a),Gt(a,u,d,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),Gt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),Gt("!",{},[],n,r)):Gt("",{},[],void 0,r)}var Wp="http://www.w3.org/1999/xlink",Yp="http://www.w3.org/XML/1998/namespace";function Au(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(Yp,t,i):t.charCodeAt(5)===58?n.setAttributeNS(Wp,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var ps={create:Au,update:Au};var xi;function Kp(){return xi||(xi=hs([ps]),xi)}function ku(r,e){let t=document.createElement("div");t.innerHTML=e,Kp()(Jr(r),Jr(t))}var wi=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,n=e.target.closest("a");if(n!==null){e.preventDefault(),window.open(n.getAttribute("href"));return}let o=e.target.closest("[drawio-diagram]");if(o!==null&&t){this.editor.actions.editDrawing(o);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.doc.head.appendChild(n)}}patchWithHtml(e){let t=this.doc.body;if(t.children.length===0){let o=document.createElement("div");this.doc.body.append(o)}let n=t.children[0];ku(n,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};var _t=null,vs,ms,gs;function Xp(r,e,t){ms=e,gs=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tu),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),vs=new URL(r).origin}function Zp(){Iu()}function Tu(r){if(!r.data||r.data.length<1||r.origin!==vs)return;let e=JSON.parse(r.data);e.event==="init"?em():e.event==="exit"?Iu():e.event==="save"?Jp(e):e.event==="export"?Qp(e):e.event==="configure"&&tm()}function Qp(r){gs&&gs(r.data)}function Jp(r){ys({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function em(){!ms||ms().then(r=>{ys({action:"load",autosave:1,xml:r})})}function tm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),ys({action:"configure",config:r})}function Iu(){window.removeEventListener("message",Tu),_t&&document.body.removeChild(_t)}function ys(r){_t.contentWindow.postMessage(JSON.stringify(r),vs)}async function rm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function nm(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var wt={show:Xp,close:Zp,upload:rm,load:nm};var Ei=class{constructor(e){this.editor=e}updateAndRender(){let e=this.editor.cm.getValue();this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e),this.editor.display.patchWithHtml(t)}insertImage(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{let o=n.thumbs.display||n.url,s=this.editor.cm.getSelection(),i="[]("+n.url+")";this.editor.cm.focus(),this.editor.cm.replaceSelection(i),this.editor.cm.setCursor(e.line,e.ch+i.length)},"gallery")}insertLink(){let e=this.editor.cm.getCursor("from"),t=this.editor.cm.getSelection()||"",n=`[${t}]()`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n);let o=t===""?-3:-1;this.editor.cm.setCursor(e.line,e.ch+n.length+o)}showImageManager(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{this.insertDrawing(n,e)},"drawio")}showLinkSelector(){let e=this.editor.cm.getCursor("from");window.$components.first("entity-selector-popup").show(n=>{let s=`[${this.editor.cm.getSelection()||n.name}](${n.link})`;this.editor.cm.focus(),this.editor.cm.replaceSelection(s),this.editor.cm.setCursor(e.line,e.ch+s.length)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=this.editor.cm.getCursor("from");wt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),wt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n),this.editor.cm.setCursor(t.line,t.ch+n.length)}editDrawing(e){let t=this.editor.config.drawioUrl;if(!t)return;let n=this.editor.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");wt.show(t,()=>wt.load(o),s=>{let i={image:s,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=this.editor.cm.getValue().split(`
+`);nn("error",e)}}var Ts={emit:nn,emitPublic:md,listen:pd,success:r=>nn("success",r),error:r=>nn("error",r),showValidationErrors:gd};async function vd(r,e={}){return Is(r,{method:"GET",params:e})}async function yd(r,e=null){return on("POST",r,e)}async function bd(r,e=null){return on("PUT",r,e)}async function xd(r,e=null){return on("PATCH",r,e)}async function wd(r,e=null){return on("DELETE",r,e)}async function on(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"),Is(e,n)}async function Is(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 Ed(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 Ed(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 Ds={get:vd,post:yd,put:bd,patch:xd,delete:wd};var oo=class{constructor(e){this.store=new Map,this.parseTranslations()}parseTranslations(){let e=document.querySelectorAll('meta[name="translation"]');for(let t of e){let n=t.getAttribute("key"),o=t.getAttribute("value");this.store.set(n,o)}}get(e,t){let n=this.getTransText(e);return this.performReplacements(n,t)}getPlural(e,t,n){let o=this.getTransText(e);return this.parsePlural(o,t,n)}parsePlural(e,t,n){let o=e.split("|"),s=/^{([0-9]+)}/,i=/^\[([0-9]+),([0-9*]+)]/,a=null;for(let l of o){let c=l.match(s);if(c!==null&&Number(c[1])===t){a=l.replace(s,"").trim();break}let u=l.match(i);if(u!==null&&Number(u[1])<=t&&(u[2]==="*"||Number(u[2])>=t)){a=l.replace(i,"").trim();break}}return a===null&&o.length>1&&(a=t===1?o[0]:o[1]),a===null&&(a=o[0]),this.performReplacements(a,n)}getTransText(e){let t=this.store.get(e);return t===void 0&&console.warn(`Translation with key "${e}" does not exist`),t}performReplacements(e,t){if(!t)return e;let n=e.match(/:([\S]+)/g);return n===null||n.forEach(o=>{let s=o.substring(1);typeof t[s]>"u"||(e=e.replace(o,t[s]))}),e}},Ls=oo;var uo={};no(uo,{first:()=>kd,firstOnElement:()=>Id,get:()=>Td,init:()=>lo,register:()=>co});function so(r){let e=n=>n.slice(0,1).toUpperCase()+n.slice(1),t=r.split("-");return t[0]+t.slice(1).map(e).join("")}function Fs(r){return r.replace(/[A-Z]/g,(e,t)=>(t>0?"-":"")+e.toLowerCase())}var Fr={},Rs={},ao=new WeakMap;function Cd(r,e){let t=Rs[r];if(t===void 0)return;let n;try{n=new t,n.$name=r,n.$el=e;let s=Sd(r,e);n.$refs=s.refs,n.$manyRefs=s.manyRefs,n.$opts=Ad(r,e),n.setup()}catch(s){console.error("Failed to create component",s,r,e)}typeof Fr[r]>"u"&&(Fr[r]=[]),Fr[r].push(n);let o=ao.get(e)||{};o[r]=n,ao.set(e,o)}function Sd(r,e){let t={},n={},o=`${r}@`,s=`[refs*="${o}"]`,i=[...e.querySelectorAll(s)];e.matches(s)&&i.push(e);for(let a of i){let l=a.getAttribute("refs").split(" ").filter(c=>c.startsWith(o)).map(c=>c.replace(o,"")).map(so);for(let c of l)t[c]=a,typeof n[c]>"u"&&(n[c]=[]),n[c].push(a)}return{refs:t,manyRefs:n}}function Ad(r,e){let t={},n=`option:${r}:`;for(let{name:o,value:s}of e.attributes)if(o.startsWith(n)){let i=o.replace(n,"");t[so(i)]=s||""}return t}function lo(r=document){let e=r.querySelectorAll("[component],[components]");for(let t of e){let n=`${t.getAttribute("component")||""} ${t.getAttribute("components")}`.toLowerCase().split(" ").filter(Boolean);for(let o of n)Cd(o,t)}}function co(r){let e=Object.keys(r);for(let t of e)Rs[Fs(t)]=r[t]}function kd(r){return(Fr[r]||[null])[0]}function Td(r){return Fr[r]||[]}function Id(r,e){return(ao.get(r)||{})[e]||null}var Cs={};no(Cs,{AddRemoveRows:()=>ln,AjaxDeleteRow:()=>cn,AjaxForm:()=>un,Attachments:()=>dn,AttachmentsList:()=>hn,AutoSubmit:()=>pn,AutoSuggest:()=>fn,BackToTop:()=>mn,BookSort:()=>Fn,ChapterContents:()=>Pn,CodeEditor:()=>Mn,CodeHighlighter:()=>$n,CodeTextarea:()=>Bn,Collapsible:()=>_n,ConfirmDialog:()=>Nn,CustomCheckbox:()=>Un,DetailsHighlighter:()=>zn,Dropdown:()=>Hn,DropdownSearch:()=>jn,Dropzone:()=>qn,EditorToolbox:()=>Gn,EntityPermissions:()=>Wn,EntitySearch:()=>Yn,EntitySelector:()=>Kn,EntitySelectorPopup:()=>Xn,EventEmitSelect:()=>Zn,ExpandToggle:()=>Qn,GlobalSearch:()=>Jn,HeaderMobileToggle:()=>ei,ImageManager:()=>ti,ImagePicker:()=>ri,ListSortControl:()=>ni,MarkdownEditor:()=>Ai,NewUserPassword:()=>ki,Notification:()=>Ti,OptionalInput:()=>Ii,PageComments:()=>Di,PageDisplay:()=>Li,PageEditor:()=>Fi,PagePicker:()=>Oi,PermissionsTable:()=>Pi,Pointer:()=>Mi,Popup:()=>$i,SettingAppColorPicker:()=>Bi,SettingColorPicker:()=>_i,SettingHomepageControl:()=>Ni,ShelfSort:()=>Ui,ShortcutInput:()=>Hi,Shortcuts:()=>zi,SortableList:()=>ji,SubmitOnChange:()=>Vi,Tabs:()=>qi,TagManager:()=>Gi,TemplateManager:()=>Wi,ToggleSwitch:()=>Yi,TriLayout:()=>Ki,UserSelect:()=>Xi,WebhookEvents:()=>Zi,WysiwygEditor:()=>eo});function ho(r,e){let t=document.querySelectorAll(r);for(let n of t)e(n)}function sn(r,e,t){for(let n of e)r.addEventListener(n,t)}function Ne(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 an(r,e){Array.isArray(r)||(r=[r]);let t=n=>{n.key==="Enter"&&e(n)};r.forEach(n=>n.addEventListener("keypress",t))}function Ve(r,e,t,n){r.addEventListener(t,function(o){let s=o.target.closest(e);s&&n.call(s,o,s)})}function Os(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 Rr(r){r.innerHTML='<div class="loading-container"><div></div><div></div><div></div></div>'}function Ps(r){let e=r.querySelectorAll(".loading-container");for(let t of e)t.remove()}function Kt(r){let e=document.createElement("div");return e.innerHTML=r,window.$components.init(e),e.children[0]}function Ft(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 Or(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 Ms(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function $s(){let r=()=>((1+Math.random())*65536|0).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}var V=class{constructor(){ur(this,"$name","");ur(this,"$el",null);ur(this,"$refs",{});ur(this,"$manyRefs",{});ur(this,"$opts",{})}setup(){}$emit(e,t={}){t.from=this;let n=this.$name,o=new CustomEvent(`${n}-${e}`,{bubbles:!0,detail:t});this.$el.dispatchEvent(o)}};var ln=class extends V{setup(){this.modelRow=this.$refs.model,this.addButton=this.$refs.add,this.removeSelector=this.$opts.removeSelector,this.rowSelector=this.$opts.rowSelector,this.setupListeners()}setupListeners(){this.addButton.addEventListener("click",this.add.bind(this)),Ve(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=$s(),n=e.querySelectorAll('[name*="randrowid"]');for(let o of n)o.name=o.name.split("randrowid").join(t)}};var cn=class extends V{setup(){this.row=this.$el,this.url=this.$opts.url,this.deleteButtons=this.$manyRefs.delete,Ne(this.deleteButtons,this.runDelete.bind(this))}runDelete(){this.row.style.opacity="0.7",this.row.style.pointerEvents="none",window.$http.delete(this.url).then(e=>{typeof e.data=="object"&&e.data.message&&window.$events.emit("success",e.data.message),this.row.remove()}).catch(e=>{this.row.style.opacity=null,this.row.style.pointerEvents=null})}};var un=class extends V{setup(){this.container=this.$el,this.responseContainer=this.container,this.url=this.$opts.url,this.method=this.$opts.method||"post",this.successMessage=this.$opts.successMessage,this.submitButtons=this.$manyRefs.submit||[],this.$opts.responseContainer&&(this.responseContainer=this.container.closest(this.$opts.responseContainer)),this.setupListeners()}setupListeners(){if(this.container.tagName==="FORM"){this.container.addEventListener("submit",this.submitRealForm.bind(this));return}an(this.container,e=>{this.submitFakeForm(),e.preventDefault()}),this.submitButtons.forEach(e=>Ne(e,this.submitFakeForm.bind(this)))}submitFakeForm(){let e=new FormData,t=this.container.querySelectorAll("[name]");for(let n of t)e.append(n.getAttribute("name"),n.value);this.submit(e)}submitRealForm(e){e.preventDefault();let t=new FormData(this.container);this.submit(t)}async submit(e){this.responseContainer.style.opacity="0.7",this.responseContainer.style.pointerEvents="none";try{let t=await window.$http[this.method.toLowerCase()](this.url,e);this.$emit("success",{formData:e}),this.responseContainer.innerHTML=t.data,this.successMessage&&window.$events.emit("success",this.successMessage)}catch(t){this.responseContainer.innerHTML=t.data}window.$components.init(this.responseContainer),this.responseContainer.style.opacity=null,this.responseContainer.style.pointerEvents=null}};var dn=class extends V{setup(){this.container=this.$el,this.pageId=this.$opts.pageId,this.editContainer=this.$refs.editContainer,this.listContainer=this.$refs.listContainer,this.mainTabs=this.$refs.mainTabs,this.list=this.$refs.list,this.setupListeners()}setupListeners(){let e=this.reloadList.bind(this);this.container.addEventListener("dropzone-success",e),this.container.addEventListener("ajax-form-success",e),this.container.addEventListener("sortable-list-sort",t=>{this.updateOrder(t.detail.ids)}),this.container.addEventListener("event-emit-select-edit",t=>{this.startEdit(t.detail.id)}),this.container.addEventListener("event-emit-select-edit-back",t=>{this.stopEdit()}),this.container.addEventListener("event-emit-select-insert",t=>{let n=t.target.closest("[data-drag-content]").getAttribute("data-drag-content"),o=JSON.parse(n);window.$events.emit("editor::insert",{html:o["text/html"],markdown:o["text/plain"]})})}reloadList(){this.stopEdit(),window.$components.firstOnElement(this.mainTabs,"tabs").show("items"),window.$http.get(`/attachments/get/page/${this.pageId}`).then(t=>{this.list.innerHTML=t.data,window.$components.init(this.list)})}updateOrder(e){window.$http.put(`/attachments/sort/page/${this.pageId}`,{order:e}).then(t=>{window.$events.emit("success",t.data.message)})}async startEdit(e){this.editContainer.classList.remove("hidden"),this.listContainer.classList.add("hidden"),Rr(this.editContainer);let t=await window.$http.get(`/attachments/edit/${e}`);this.editContainer.innerHTML=t.data,window.$components.init(this.editContainer)}stopEdit(){this.editContainer.classList.add("hidden"),this.listContainer.classList.remove("hidden")}};var hn=class extends V{setup(){this.container=this.$el,this.setupListeners()}setupListeners(){let e=t=>t.key==="Control"||t.key==="Meta";window.addEventListener("keydown",t=>{e(t)&&this.addOpenQueryToLinks()},{passive:!0}),window.addEventListener("keyup",t=>{e(t)&&this.removeOpenQueryFromLinks()},{passive:!0})}addOpenQueryToLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href.split("?")[1]!=="open=true"&&(t.href=t.href+"?open=true",t.setAttribute("target","_blank"))}removeOpenQueryFromLinks(){let e=this.container.querySelectorAll("a.attachment-file");for(let t of e)t.href=t.href.split("?")[0],t.removeAttribute("target")}};var po={},fn=class extends V{setup(){this.parent=this.$el.parentElement,this.container=this.$el,this.type=this.$opts.type,this.url=this.$opts.url,this.input=this.$refs.input,this.list=this.$refs.list,this.lastPopulated=0,this.setupListeners()}setupListeners(){this.input.addEventListener("input",this.requestSuggestions.bind(this)),this.input.addEventListener("focus",this.requestSuggestions.bind(this)),this.input.addEventListener("keydown",e=>{e.key==="Tab"&&this.hideSuggestions()}),this.input.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this)),this.container.addEventListener("keydown",this.containerKeyDown.bind(this)),Ve(this.list,"button","click",(e,t)=>{this.selectSuggestion(t.textContent)}),Ve(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.toLowerCase(),o=(await this.loadSuggestions(t,e)).filter(s=>t===""||s.toLowerCase().startsWith(t)).slice(0,10);this.displaySuggestions(o)}getNameFilterIfNeeded(){return this.type!=="value"?null:this.parent.querySelector("input").value}async loadSuggestions(e,t=null){e=e.slice(0,4);let n={search:e,name:t},o=`${this.url}:${JSON.stringify(n)}`;if(po[o])return po[o];let s=await window.$http.get(this.url,n);return po[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">${Ms(t)}</button></li>`).join(""),this.list.style.display="block";for(let t of this.list.querySelectorAll("button"))t.addEventListener("blur",this.hideSuggestionsIfFocusedLost.bind(this))}hideSuggestions(){this.list.style.display="none"}hideSuggestionsIfFocusedLost(e){this.container.contains(e.relatedTarget)||this.hideSuggestions()}};var pn=class extends V{setup(){this.form=this.$el,this.form.submit()}};var mn=class extends V{setup(){if(this.button=this.$el,this.targetElem=document.getElementById("header"),this.showing=!1,this.breakPoint=1200,document.body.classList.contains("flexbox")){this.button.style.display="none";return}this.button.addEventListener("click",this.scrollToTop.bind(this)),window.addEventListener("scroll",this.onPageScroll.bind(this))}onPageScroll(){let e=document.documentElement.scrollTop||document.body.scrollTop||0;!this.showing&&e>this.breakPoint?(this.button.style.display="block",this.showing=!0,setTimeout(()=>{this.button.style.opacity=.4},1)):this.showing&&e<this.breakPoint&&(this.button.style.opacity=0,this.showing=!1,setTimeout(()=>{this.button.style.display="none"},500))}scrollToTop(){let e=this.targetElem.getBoundingClientRect().top,t=document.documentElement.scrollTop?document.documentElement:document.body,n=300,o=Date.now(),s=this.targetElem.getBoundingClientRect().top;function i(){let a=1-(Date.now()-o)/n,l=Math.abs(a*s);a>0?(t.scrollTop=l,requestAnimationFrame(i.bind(this))):t.scrollTop=e}requestAnimationFrame(i.bind(this))}};function Bs(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 Pt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bs(Object(t),!0).forEach(function(n){Dd(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Bs(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function xn(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xn=function(e){return typeof e}:xn=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xn(r)}function Dd(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Vt(){return Vt=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},Vt.apply(this,arguments)}function Ld(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 Fd(r,e){if(r==null)return{};var t=Ld(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 Rd="1.15.0";function jt(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var qt=jt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Hr=jt(/Edge/i),_s=jt(/firefox/i),Br=jt(/safari/i)&&!jt(/chrome/i)&&!jt(/android/i),Gs=jt(/iP(ad|od|hone)/i),Ws=jt(/chrome/i)&&jt(/android/i),Ys={capture:!1,passive:!1};function $e(r,e,t){r.addEventListener(e,t,!qt&&Ys)}function Fe(r,e,t){r.removeEventListener(e,t,!qt&&Ys)}function An(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 Od(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function Rt(r,e,t,n){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&An(r,e):An(r,e))||n&&r===t)return r;if(r===t)break}while(r=Od(r))}return null}var Ns=/\s+/g;function vt(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var n=(" "+r.className+" ").replace(Ns," ").replace(" "+e+" "," ");r.className=(n+(t?" "+e:"")).replace(Ns," ")}}function ve(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 mr(r,e){var t="";if(typeof r=="string")t=r;else do{var n=ve(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 Ks(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 Ot(){var r=document.scrollingElement;return r||document.documentElement}function rt(r,e,t,n,o){if(!(!r.getBoundingClientRect&&r!==window)){var s,i,a,l,c,u,d;if(r!==window&&r.parentNode&&r!==Ot()?(s=r.getBoundingClientRect(),i=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,d=s.width):(i=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,d=window.innerWidth),(e||t)&&r!==window&&(o=o||r.parentNode,!qt))do if(o&&o.getBoundingClientRect&&(ve(o,"transform")!=="none"||t&&ve(o,"position")!=="static")){var h=o.getBoundingClientRect();i-=h.top+parseInt(ve(o,"border-top-width")),a-=h.left+parseInt(ve(o,"border-left-width")),l=i+s.height,c=a+s.width;break}while(o=o.parentNode);if(n&&r!==window){var f=mr(o||r),p=f&&f.a,v=f&&f.d;f&&(i/=v,a/=p,d/=p,u/=v,l=i+u,c=a+d)}return{top:i,left:a,bottom:l,right:c,width:d,height:u}}}function Us(r,e,t){for(var n=Qt(r,!0),o=rt(r)[e];n;){var s=rt(n)[t],i=void 0;if(t==="top"||t==="left"?i=o>=s:i=o<=s,!i)return n;if(n===Ot())break;n=Qt(n,!1)}return!1}function gr(r,e,t,n){for(var o=0,s=0,i=r.children;s<i.length;){if(i[s].style.display!=="none"&&i[s]!==ye.ghost&&(n||i[s]!==ye.dragged)&&Rt(i[s],t.draggable,r,!1)){if(o===e)return i[s];o++}s++}return null}function Io(r,e){for(var t=r.lastElementChild;t&&(t===ye.ghost||ve(t,"display")==="none"||e&&!An(t,e));)t=t.previousElementSibling;return t||null}function St(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==ye.clone&&(!e||An(r,e))&&t++;return t}function zs(r){var e=0,t=0,n=Ot();if(r)do{var o=mr(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 Pd(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 Qt(r,e){if(!r||!r.getBoundingClientRect)return Ot();var t=r,n=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var o=ve(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 Ot();if(n||e)return t;n=!0}}while(t=t.parentNode);return Ot()}function Md(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function mo(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 _r;function Xs(r,e){return function(){if(!_r){var t=arguments,n=this;t.length===1?r.call(n,t[0]):r.apply(n,t),_r=setTimeout(function(){_r=void 0},e)}}}function $d(){clearTimeout(_r),_r=void 0}function Zs(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Qs(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 bt="Sortable"+new Date().getTime();function Bd(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(ve(o,"display")==="none"||o===ye.ghost)){r.push({target:o,rect:rt(o)});var s=Pt({},r[r.length-1].rect);if(o.thisAnimationDuration){var i=mr(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(Pd(r,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(e),typeof n=="function"&&n();return}var s=!1,i=0;r.forEach(function(a){var l=0,c=a.target,u=c.fromRect,d=rt(c),h=c.prevFromRect,f=c.prevToRect,p=a.rect,v=mr(c,!0);v&&(d.top-=v.f,d.left-=v.e),c.toRect=d,c.thisAnimationDuration&&mo(h,d)&&!mo(u,d)&&(p.top-d.top)/(p.left-d.left)===(u.top-d.top)/(u.left-d.left)&&(l=Nd(p,h,f,o.options)),mo(d,u)||(c.prevFromRect=u,c.prevToRect=d,l||(l=o.options.animation),o.animate(c,p,d,l)),l&&(s=!0,i=Math.max(i,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof n=="function"&&n()},i):typeof n=="function"&&n(),r=[]},animate:function(n,o,s,i){if(i){ve(n,"transition",""),ve(n,"transform","");var a=mr(this.el),l=a&&a.a,c=a&&a.d,u=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);n.animatingX=!!u,n.animatingY=!!d,ve(n,"transform","translate3d("+u+"px,"+d+"px,0)"),this.forRepaintDummy=_d(n),ve(n,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:"")),ve(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){ve(n,"transition",""),ve(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},i)}}}}function _d(r){return r.offsetWidth}function Nd(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 dr=[],go={initializeByDefault:!0},jr={mount:function(e){for(var t in go)go.hasOwnProperty(t)&&!(t in e)&&(e[t]=go[t]);dr.forEach(function(n){if(n.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),dr.push(e)},pluginEvent:function(e,t,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=e+"Global";dr.forEach(function(i){!t[i.pluginName]||(t[i.pluginName][s]&&t[i.pluginName][s](Pt({sortable:t},n)),t.options[i.pluginName]&&t[i.pluginName][e]&&t[i.pluginName][e](Pt({sortable:t},n)))})},initializePlugins:function(e,t,n,o){dr.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,Vt(n,c.defaults)}});for(var s in e.options)if(!!e.options.hasOwnProperty(s)){var i=this.modifyOption(e,s,e.options[s]);typeof i<"u"&&(e.options[s]=i)}},getEventProperties:function(e,t){var n={};return dr.forEach(function(o){typeof o.eventProperties=="function"&&Vt(n,o.eventProperties.call(t[o.pluginName],e))}),n},modifyOption:function(e,t,n){var o;return dr.forEach(function(s){!e[s.pluginName]||s.optionListeners&&typeof s.optionListeners[t]=="function"&&(o=s.optionListeners[t].call(e[s.pluginName],n))}),o}};function Ud(r){var e=r.sortable,t=r.rootEl,n=r.name,o=r.targetEl,s=r.cloneEl,i=r.toEl,a=r.fromEl,l=r.oldIndex,c=r.newIndex,u=r.oldDraggableIndex,d=r.newDraggableIndex,h=r.originalEvent,f=r.putSortable,p=r.extraEventProperties;if(e=e||t&&t[bt],!!e){var v,y=e.options,b="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!qt&&!Hr?v=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(v=document.createEvent("Event"),v.initEvent(n,!0,!0)),v.to=i||t,v.from=a||t,v.item=o||t,v.clone=s,v.oldIndex=l,v.newIndex=c,v.oldDraggableIndex=u,v.newDraggableIndex=d,v.originalEvent=h,v.pullMode=f?f.lastPutMode:void 0;var x=Pt(Pt({},p),jr.getEventProperties(n,e));for(var I in x)v[I]=x[I];t&&t.dispatchEvent(v),y[b]&&y[b].call(e,v)}}var zd=["evt"],pt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=Fd(n,zd);jr.pluginEvent.bind(ye)(e,t,Pt({dragEl:te,parentEl:Qe,ghostEl:Ee,rootEl:Ge,nextEl:nr,lastDownEl:wn,cloneEl:Ke,cloneHidden:Zt,dragStarted:Pr,putSortable:ot,activeSortable:ye.active,originalEvent:o,oldIndex:pr,oldDraggableIndex:Nr,newIndex:yt,newDraggableIndex:Xt,hideGhostForTarget:ra,unhideGhostForTarget:na,cloneNowHidden:function(){Zt=!0},cloneNowShown:function(){Zt=!1},dispatchSortableEvent:function(a){dt({sortable:t,name:a,originalEvent:o})}},s))};function dt(r){Ud(Pt({putSortable:ot,cloneEl:Ke,targetEl:te,rootEl:Ge,oldIndex:pr,oldDraggableIndex:Nr,newIndex:yt,newDraggableIndex:Xt},r))}var te,Qe,Ee,Ge,nr,wn,Ke,Zt,pr,yt,Nr,Xt,gn,ot,fr=!1,kn=!1,Tn=[],tr,Tt,vo,yo,Hs,js,Pr,hr,Ur,zr=!1,vn=!1,En,ct,bo=[],So=!1,In=[],Ln=typeof document<"u",yn=Gs,Vs=Hr||qt?"cssFloat":"float",Hd=Ln&&!Ws&&!Gs&&"draggable"in document.createElement("div"),Js=function(){if(!!Ln){if(qt)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),ea=function(e,t){var n=ve(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=gr(e,0,t),i=gr(e,1,t),a=s&&ve(s),l=i&&ve(i),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+rt(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+rt(i).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return i&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&n[Vs]==="none"||i&&n[Vs]==="none"&&c+u>o)?"vertical":"horizontal"},jd=function(e,t,n){var o=n?e.left:e.top,s=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,c=n?t.width:t.height;return o===a||s===l||o+i/2===a+c/2},Vd=function(e,t){var n;return Tn.some(function(o){var s=o[bt].options.emptyInsertThreshold;if(!(!s||Io(o))){var i=rt(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},ta=function(e){function t(s,i){return function(a,l,c,u){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(i||d))return!0;if(s==null||s===!1)return!1;if(i&&s==="clone")return s;if(typeof s=="function")return t(s(a,l,c,u),i)(a,l,c,u);var h=(i?a:l).options.group.name;return s===!0||typeof s=="string"&&s===h||s.join&&s.indexOf(h)>-1}}var n={},o=e.group;(!o||xn(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},ra=function(){!Js&&Ee&&ve(Ee,"display","none")},na=function(){!Js&&Ee&&ve(Ee,"display","")};Ln&&!Ws&&document.addEventListener("click",function(r){if(kn)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),kn=!1,!1},!0);var rr=function(e){if(te){e=e.touches?e.touches[0]:e;var t=Vd(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[bt]._onDragOver(n)}}},qd=function(e){te&&te.parentNode[bt]._isOutsideThisEl(e.target)};function ye(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=Vt({},e),r[bt]=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 ea(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(i,a){i.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ye.supportPointer!==!1&&"PointerEvent"in window&&!Br,emptyInsertThreshold:5};jr.initializePlugins(this,r,t);for(var n in t)!(n in e)&&(e[n]=t[n]);ta(e);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=e.forceFallback?!1:Hd,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?$e(r,"pointerdown",this._onTapStart):($e(r,"mousedown",this._onTapStart),$e(r,"touchstart",this._onTapStart)),this.nativeDraggable&&($e(r,"dragover",this),$e(r,"dragenter",this)),Tn.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Vt(this,Bd())}ye.prototype={constructor:ye,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(hr=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,te):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var t=this,n=this.el,o=this.options,s=o.preventOnFilter,i=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=o.filter;if(Jd(n),!te&&!(/mousedown|pointerdown/.test(i)&&e.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Br&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Rt(l,o.draggable,n,!1),!(l&&l.animated)&&wn!==l)){if(pr=St(l),Nr=St(l,o.draggable),typeof u=="function"){if(u.call(this,e,l,this)){dt({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),pt("filter",t,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(d){if(d=Rt(c,d.trim(),n,!1),d)return dt({sortable:t,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),pt("filter",t,{evt:e}),!0}),u)){s&&e.cancelable&&e.preventDefault();return}o.handle&&!Rt(c,o.handle,n,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,t,n){var o=this,s=o.el,i=o.options,a=s.ownerDocument,l;if(n&&!te&&n.parentNode===s){var c=rt(n);if(Ge=s,te=n,Qe=te.parentNode,nr=te.nextSibling,wn=n,gn=i.group,ye.dragged=te,tr={target:te,clientX:(t||e).clientX,clientY:(t||e).clientY},Hs=tr.clientX-c.left,js=tr.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,te.style["will-change"]="all",l=function(){if(pt("delayEnded",o,{evt:e}),ye.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!_s&&o.nativeDraggable&&(te.draggable=!0),o._triggerDragStart(e,t),dt({sortable:o,name:"choose",originalEvent:e}),vt(te,i.chosenClass,!0)},i.ignore.split(",").forEach(function(u){Ks(te,u.trim(),xo)}),$e(a,"dragover",rr),$e(a,"mousemove",rr),$e(a,"touchmove",rr),$e(a,"mouseup",o._onDrop),$e(a,"touchend",o._onDrop),$e(a,"touchcancel",o._onDrop),_s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,te.draggable=!0),pt("delayStart",this,{evt:e}),i.delay&&(!i.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Hr||qt))){if(ye.eventCanceled){this._onDrop();return}$e(a,"mouseup",o._disableDelayedDrag),$e(a,"touchend",o._disableDelayedDrag),$e(a,"touchcancel",o._disableDelayedDrag),$e(a,"mousemove",o._delayedDragTouchMoveHandler),$e(a,"touchmove",o._delayedDragTouchMoveHandler),i.supportPointer&&$e(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,i.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){te&&xo(te),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;Fe(e,"mouseup",this._disableDelayedDrag),Fe(e,"touchend",this._disableDelayedDrag),Fe(e,"touchcancel",this._disableDelayedDrag),Fe(e,"mousemove",this._delayedDragTouchMoveHandler),Fe(e,"touchmove",this._delayedDragTouchMoveHandler),Fe(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?$e(document,"pointermove",this._onTouchMove):t?$e(document,"touchmove",this._onTouchMove):$e(document,"mousemove",this._onTouchMove):($e(te,"dragend",this),$e(Ge,"dragstart",this._onDragStart));try{document.selection?Cn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(fr=!1,Ge&&te){pt("dragStarted",this,{evt:t}),this.nativeDraggable&&$e(document,"dragover",qd);var n=this.options;!e&&vt(te,n.dragClass,!1),vt(te,n.ghostClass,!0),ye.active=this,e&&this._appendGhost(),dt({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(Tt){this._lastX=Tt.clientX,this._lastY=Tt.clientY,ra();for(var e=document.elementFromPoint(Tt.clientX,Tt.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Tt.clientX,Tt.clientY),e!==t);)t=e;if(te.parentNode[bt]._isOutsideThisEl(e),t)do{if(t[bt]){var n=void 0;if(n=t[bt]._onDragOver({clientX:Tt.clientX,clientY:Tt.clientY,target:e,rootEl:t}),n&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);na()}},_onTouchMove:function(e){if(tr){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,s=e.touches?e.touches[0]:e,i=Ee&&mr(Ee,!0),a=Ee&&i&&i.a,l=Ee&&i&&i.d,c=yn&&ct&&zs(ct),u=(s.clientX-tr.clientX+o.x)/(a||1)+(c?c[0]-bo[0]:0)/(a||1),d=(s.clientY-tr.clientY+o.y)/(l||1)+(c?c[1]-bo[1]:0)/(l||1);if(!ye.active&&!fr){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(e,!0)}if(Ee){i?(i.e+=u-(vo||0),i.f+=d-(yo||0)):i={a:1,b:0,c:0,d:1,e:u,f:d};var h="matrix(".concat(i.a,",").concat(i.b,",").concat(i.c,",").concat(i.d,",").concat(i.e,",").concat(i.f,")");ve(Ee,"webkitTransform",h),ve(Ee,"mozTransform",h),ve(Ee,"msTransform",h),ve(Ee,"transform",h),vo=u,yo=d,Tt=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!Ee){var e=this.options.fallbackOnBody?document.body:Ge,t=rt(te,!0,yn,!0,e),n=this.options;if(yn){for(ct=e;ve(ct,"position")==="static"&&ve(ct,"transform")==="none"&&ct!==document;)ct=ct.parentNode;ct!==document.body&&ct!==document.documentElement?(ct===document&&(ct=Ot()),t.top+=ct.scrollTop,t.left+=ct.scrollLeft):ct=Ot(),bo=zs(ct)}Ee=te.cloneNode(!0),vt(Ee,n.ghostClass,!1),vt(Ee,n.fallbackClass,!0),vt(Ee,n.dragClass,!0),ve(Ee,"transition",""),ve(Ee,"transform",""),ve(Ee,"box-sizing","border-box"),ve(Ee,"margin",0),ve(Ee,"top",t.top),ve(Ee,"left",t.left),ve(Ee,"width",t.width),ve(Ee,"height",t.height),ve(Ee,"opacity","0.8"),ve(Ee,"position",yn?"absolute":"fixed"),ve(Ee,"zIndex","100000"),ve(Ee,"pointerEvents","none"),ye.ghost=Ee,e.appendChild(Ee),ve(Ee,"transform-origin",Hs/parseInt(Ee.style.width)*100+"% "+js/parseInt(Ee.style.height)*100+"%")}},_onDragStart:function(e,t){var n=this,o=e.dataTransfer,s=n.options;if(pt("dragStart",this,{evt:e}),ye.eventCanceled){this._onDrop();return}pt("setupClone",this),ye.eventCanceled||(Ke=Qs(te),Ke.removeAttribute("id"),Ke.draggable=!1,Ke.style["will-change"]="",this._hideClone(),vt(Ke,this.options.chosenClass,!1),ye.clone=Ke),n.cloneId=Cn(function(){pt("clone",n),!ye.eventCanceled&&(n.options.removeCloneOnHide||Ge.insertBefore(Ke,te),n._hideClone(),dt({sortable:n,name:"clone"}))}),!t&&vt(te,s.dragClass,!0),t?(kn=!0,n._loopId=setInterval(n._emulateDragOver,50)):(Fe(document,"mouseup",n._onDrop),Fe(document,"touchend",n._onDrop),Fe(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,te)),$e(document,"drop",n),ve(te,"transform","translateZ(0)")),fr=!0,n._dragStartId=Cn(n._dragStarted.bind(n,t,e)),$e(document,"selectstart",n),Pr=!0,Br&&ve(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,n=e.target,o,s,i,a=this.options,l=a.group,c=ye.active,u=gn===l,d=a.sort,h=ot||c,f,p=this,v=!1;if(So)return;function y(ie,xe){pt(ie,p,Pt({evt:e,isOwner:u,axis:f?"vertical":"horizontal",revert:i,dragRect:o,targetRect:s,canSort:d,fromSortable:h,target:n,completed:x,onMove:function(we,Re){return bn(Ge,t,te,o,we,rt(we),e,Re)},changed:I},xe))}function b(){y("dragOverAnimationCapture"),p.captureAnimationState(),p!==h&&h.captureAnimationState()}function x(ie){return y("dragOverCompleted",{insertion:ie}),ie&&(u?c._hideClone():c._showClone(p),p!==h&&(vt(te,ot?ot.options.ghostClass:c.options.ghostClass,!1),vt(te,a.ghostClass,!0)),ot!==p&&p!==ye.active?ot=p:p===ye.active&&ot&&(ot=null),h===p&&(p._ignoreWhileAnimating=n),p.animateAll(function(){y("dragOverAnimationComplete"),p._ignoreWhileAnimating=null}),p!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(n===te&&!te.animated||n===t&&!n.animated)&&(hr=null),!a.dragoverBubble&&!e.rootEl&&n!==document&&(te.parentNode[bt]._isOutsideThisEl(e.target),!ie&&rr(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),v=!0}function I(){yt=St(te),Xt=St(te,a.draggable),dt({sortable:p,name:"change",toEl:t,newIndex:yt,newDraggableIndex:Xt,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),n=Rt(n,a.draggable,t,!0),y("dragOver"),ye.eventCanceled)return v;if(te.contains(e.target)||n.animated&&n.animatingX&&n.animatingY||p._ignoreWhileAnimating===n)return x(!1);if(kn=!1,c&&!a.disabled&&(u?d||(i=Qe!==Ge):ot===this||(this.lastPutMode=gn.checkPull(this,c,te,e))&&l.checkPut(this,c,te,e))){if(f=this._getDirection(e,n)==="vertical",o=rt(te),y("dragOverValid"),ye.eventCanceled)return v;if(i)return Qe=Ge,b(),this._hideClone(),y("revert"),ye.eventCanceled||(nr?Ge.insertBefore(te,nr):Ge.appendChild(te)),x(!0);var C=Io(t,a.draggable);if(!C||Kd(e,f,this)&&!C.animated){if(C===te)return x(!1);if(C&&t===e.target&&(n=C),n&&(s=rt(n)),bn(Ge,t,te,o,n,s,e,!!n)!==!1)return b(),C&&C.nextSibling?t.insertBefore(te,C.nextSibling):t.appendChild(te),Qe=t,I(),x(!0)}else if(C&&Yd(e,f,this)){var M=gr(t,0,a,!0);if(M===te)return x(!1);if(n=M,s=rt(n),bn(Ge,t,te,o,n,s,e,!1)!==!1)return b(),t.insertBefore(te,M),Qe=t,I(),x(!0)}else if(n.parentNode===t){s=rt(n);var S=0,O,A=te.parentNode!==t,D=!jd(te.animated&&te.toRect||o,n.animated&&n.toRect||s,f),T=f?"top":"left",P=Us(n,"top","top")||Us(te,"top","top"),B=P?P.scrollTop:void 0;hr!==n&&(O=s[T],zr=!1,vn=!D&&a.invertSwap||A),S=Xd(e,n,s,f,D?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vn,hr===n);var _;if(S!==0){var j=St(te);do j-=S,_=Qe.children[j];while(_&&(ve(_,"display")==="none"||_===Ee))}if(S===0||_===n)return x(!1);hr=n,Ur=S;var Q=n.nextElementSibling,Y=!1;Y=S===1;var re=bn(Ge,t,te,o,n,s,e,Y);if(re!==!1)return(re===1||re===-1)&&(Y=re===1),So=!0,setTimeout(Wd,30),b(),Y&&!Q?t.appendChild(te):n.parentNode.insertBefore(te,Y?Q:n),P&&Zs(P,0,B-P.scrollTop),Qe=te.parentNode,O!==void 0&&!vn&&(En=Math.abs(O-rt(n)[T])),I(),x(!0)}if(t.contains(te))return x(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){Fe(document,"mousemove",this._onTouchMove),Fe(document,"touchmove",this._onTouchMove),Fe(document,"pointermove",this._onTouchMove),Fe(document,"dragover",rr),Fe(document,"mousemove",rr),Fe(document,"touchmove",rr)},_offUpEvents:function(){var e=this.el.ownerDocument;Fe(e,"mouseup",this._onDrop),Fe(e,"touchend",this._onDrop),Fe(e,"pointerup",this._onDrop),Fe(e,"touchcancel",this._onDrop),Fe(document,"selectstart",this)},_onDrop:function(e){var t=this.el,n=this.options;if(yt=St(te),Xt=St(te,n.draggable),pt("drop",this,{evt:e}),Qe=te&&te.parentNode,yt=St(te),Xt=St(te,n.draggable),ye.eventCanceled){this._nulling();return}fr=!1,vn=!1,zr=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ao(this.cloneId),Ao(this._dragStartId),this.nativeDraggable&&(Fe(document,"drop",this),Fe(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Br&&ve(document.body,"user-select",""),ve(te,"transform",""),e&&(Pr&&(e.cancelable&&e.preventDefault(),!n.dropBubble&&e.stopPropagation()),Ee&&Ee.parentNode&&Ee.parentNode.removeChild(Ee),(Ge===Qe||ot&&ot.lastPutMode!=="clone")&&Ke&&Ke.parentNode&&Ke.parentNode.removeChild(Ke),te&&(this.nativeDraggable&&Fe(te,"dragend",this),xo(te),te.style["will-change"]="",Pr&&!fr&&vt(te,ot?ot.options.ghostClass:this.options.ghostClass,!1),vt(te,this.options.chosenClass,!1),dt({sortable:this,name:"unchoose",toEl:Qe,newIndex:null,newDraggableIndex:null,originalEvent:e}),Ge!==Qe?(yt>=0&&(dt({rootEl:Qe,name:"add",toEl:Qe,fromEl:Ge,originalEvent:e}),dt({sortable:this,name:"remove",toEl:Qe,originalEvent:e}),dt({rootEl:Qe,name:"sort",toEl:Qe,fromEl:Ge,originalEvent:e}),dt({sortable:this,name:"sort",toEl:Qe,originalEvent:e})),ot&&ot.save()):yt!==pr&&yt>=0&&(dt({sortable:this,name:"update",toEl:Qe,originalEvent:e}),dt({sortable:this,name:"sort",toEl:Qe,originalEvent:e})),ye.active&&((yt==null||yt===-1)&&(yt=pr,Xt=Nr),dt({sortable:this,name:"end",toEl:Qe,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){pt("nulling",this),Ge=te=Qe=Ee=nr=Ke=wn=Zt=tr=Tt=Pr=yt=Xt=pr=Nr=hr=Ur=ot=gn=ye.dragged=ye.ghost=ye.clone=ye.active=null,In.forEach(function(e){e.checked=!0}),In.length=vo=yo=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":te&&(this._onDragOver(e),Gd(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],Rt(t,i.draggable,this.el,!1)&&e.push(t.getAttribute(i.dataIdAttr)||Qd(t));return e},sort:function(e,t){var n={},o=this.el;this.toArray().forEach(function(s,i){var a=o.children[i];Rt(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 Rt(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=jr.modifyOption(this,e,t);typeof o<"u"?n[e]=o:n[e]=t,e==="group"&&ta(n)},destroy:function(){pt("destroy",this);var e=this.el;e[bt]=null,Fe(e,"mousedown",this._onTapStart),Fe(e,"touchstart",this._onTapStart),Fe(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(Fe(e,"dragover",this),Fe(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Tn.splice(Tn.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Zt){if(pt("hideClone",this),ye.eventCanceled)return;ve(Ke,"display","none"),this.options.removeCloneOnHide&&Ke.parentNode&&Ke.parentNode.removeChild(Ke),Zt=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Zt){if(pt("showClone",this),ye.eventCanceled)return;te.parentNode==Ge&&!this.options.group.revertClone?Ge.insertBefore(Ke,te):nr?Ge.insertBefore(Ke,nr):Ge.appendChild(Ke),this.options.group.revertClone&&this.animate(te,Ke),ve(Ke,"display",""),Zt=!1}}};function Gd(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function bn(r,e,t,n,o,s,i,a){var l,c=r[bt],u=c.options.onMove,d;return window.CustomEvent&&!qt&&!Hr?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||rt(e),l.willInsertAfter=a,l.originalEvent=i,r.dispatchEvent(l),u&&(d=u.call(c,l,i)),d}function xo(r){r.draggable=!1}function Wd(){So=!1}function Yd(r,e,t){var n=rt(gr(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 Kd(r,e,t){var n=rt(Io(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 Xd(r,e,t,n,o,s,i,a){var l=n?r.clientY:r.clientX,c=n?t.height:t.width,u=n?t.top:t.left,d=n?t.bottom:t.right,h=!1;if(!i){if(a&&En<c*o){if(!zr&&(Ur===1?l>u+c*s/2:l<d-c*s/2)&&(zr=!0),zr)h=!0;else if(Ur===1?l<u+En:l>d-En)return-Ur}else if(l>u+c*(1-o)/2&&l<d-c*(1-o)/2)return Zd(e)}return h=h||i,h&&(l<u+c*s/2||l>d-c*s/2)?l>u+c/2?1:-1:0}function Zd(r){return St(te)<St(r)?1:-1}function Qd(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 Jd(r){In.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var n=e[t];n.checked&&In.push(n)}}function Cn(r){return setTimeout(r,0)}function Ao(r){return clearTimeout(r)}Ln&&$e(document,"touchmove",function(r){(ye.active||fr)&&r.cancelable&&r.preventDefault()});ye.utils={on:$e,off:Fe,css:ve,find:Ks,is:function(e,t){return!!Rt(e,t,e,!1)},extend:Md,throttle:Xs,closest:Rt,toggleClass:vt,clone:Qs,index:St,nextTick:Cn,cancelNextTick:Ao,detectDirection:ea,getChild:gr};ye.get=function(r){return r[bt]};ye.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(ye.utils=Pt(Pt({},ye.utils),n.utils)),jr.mount(n)})};ye.create=function(r,e){return new ye(r,e)};ye.version=Rd;var et=[],Mr,ko,To=!1,wo,Eo,Dn,$r;function eh(){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?$e(document,"dragover",this._handleAutoScroll):this.options.supportPointer?$e(document,"pointermove",this._handleFallbackAutoScroll):n.touches?$e(document,"touchmove",this._handleFallbackAutoScroll):$e(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var n=t.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?Fe(document,"dragover",this._handleAutoScroll):(Fe(document,"pointermove",this._handleFallbackAutoScroll),Fe(document,"touchmove",this._handleFallbackAutoScroll),Fe(document,"mousemove",this._handleFallbackAutoScroll)),qs(),Sn(),$d()},nulling:function(){Dn=ko=Mr=To=$r=wo=Eo=null,et.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(Dn=t,n||this.options.forceAutoScrollFallback||Hr||qt||Br){Co(t,this.options,a,n);var l=Qt(a,!0);To&&(!$r||s!==wo||i!==Eo)&&($r&&qs(),$r=setInterval(function(){var c=Qt(document.elementFromPoint(s,i),!0);c!==l&&(l=c,Sn()),Co(t,o.options,c,n)},10),wo=s,Eo=i)}else{if(!this.options.bubbleScroll||Qt(a,!0)===Ot()){Sn();return}Co(t,this.options,Qt(a,!1),!1)}}},Vt(r,{pluginName:"scroll",initializeByDefault:!0})}function Sn(){et.forEach(function(r){clearInterval(r.pid)}),et=[]}function qs(){clearInterval($r)}var Co=Xs(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=Ot(),c=!1,u;ko!==t&&(ko=t,Sn(),Mr=e.scroll,u=e.scrollFn,Mr===!0&&(Mr=Qt(t,!0)));var d=0,h=Mr;do{var f=h,p=rt(f),v=p.top,y=p.bottom,b=p.left,x=p.right,I=p.width,C=p.height,M=void 0,S=void 0,O=f.scrollWidth,A=f.scrollHeight,D=ve(f),T=f.scrollLeft,P=f.scrollTop;f===l?(M=I<O&&(D.overflowX==="auto"||D.overflowX==="scroll"||D.overflowX==="visible"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"||D.overflowY==="visible")):(M=I<O&&(D.overflowX==="auto"||D.overflowX==="scroll"),S=C<A&&(D.overflowY==="auto"||D.overflowY==="scroll"));var B=M&&(Math.abs(x-o)<=i&&T+I<O)-(Math.abs(b-o)<=i&&!!T),_=S&&(Math.abs(y-s)<=i&&P+C<A)-(Math.abs(v-s)<=i&&!!P);if(!et[d])for(var j=0;j<=d;j++)et[j]||(et[j]={});(et[d].vx!=B||et[d].vy!=_||et[d].el!==f)&&(et[d].el=f,et[d].vx=B,et[d].vy=_,clearInterval(et[d].pid),(B!=0||_!=0)&&(c=!0,et[d].pid=setInterval(function(){n&&this.layer===0&&ye.active._onTouchMove(Dn);var Q=et[this.layer].vy?et[this.layer].vy*a:0,Y=et[this.layer].vx?et[this.layer].vx*a:0;typeof u=="function"&&u.call(ye.dragged.parentNode[bt],Y,Q,r,Dn,et[this.layer].el)!=="continue"||Zs(et[this.layer].el,Y,Q)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&h!==l&&(h=Qt(h,!1)));To=c}},30),ia=function(e){var t=e.originalEvent,n=e.putSortable,o=e.dragEl,s=e.activeSortable,i=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(!!t){var c=n||s;a();var u=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,d=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(d)&&(i("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Do(){}Do.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=gr(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:ia};Vt(Do,{pluginName:"revertOnSpill"});function Lo(){}Lo.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:ia};Vt(Lo,{pluginName:"removeOnSpill"});ye.mount(new eh);ye.mount(Lo,Do);var vr=ye;var oa={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}},Fn=class extends V{setup(){this.container=this.$el,this.sortContainer=this.$refs.sortContainer,this.input=this.$refs.input;let e=this.container.querySelector(".sort-box");this.setupBookSortable(e),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=oa[a];t&&n.includes(a)&&(l=function(c,u){return 0-oa[a](c,u)});for(let c of i)Array.from(c.children).filter(d=>d.matches("li")).sort(l).forEach(d=>{c.appendChild(d)});e=a,this.updateMapInput()})}bookSelect(e){if(this.container.querySelector(`[data-type="book"][data-id="${e.id}"]`)!==null)return;let n=e.link+"/sort-item";window.$http.get(n).then(o=>{let s=Kt(o.data);this.sortContainer.append(s),this.setupBookSortable(s)})}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 vr(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.container.querySelectorAll(".sort-list");for(let n of t){let o=n.closest('[data-type="book"]').getAttribute("data-id"),s=Array.from(n.children).filter(i=>i.matches('[data-type="page"], [data-type="chapter"]'));for(let i=0;i<s.length;i++)this.addBookChildToMap(s[i],i,o,e)}return e}addBookChildToMap(e,t,n,o){let s=e.getAttribute("data-type"),i=!1,a=e.getAttribute("data-id");o.push({id:a,sort:t,parentChapter:i,type:s,book:n});let l=e.querySelectorAll('[data-type="page"]');for(let c=0;c<l.length;c++)o.push({id:l[c].getAttribute("data-id"),sort:c,parentChapter:a,type:"page",book:n})}};var Rn=new WeakMap;function sa(r,e=400,t=null){qr(r),r.style.display="block",Vr(r,{opacity:["0","1"]},e,()=>{t&&t()})}function On(r,e=400,t=null){qr(r),Vr(r,{opacity:["1","0"]},e,()=>{r.style.display="none",t&&t()})}function yr(r,e=400){qr(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"]};Vr(r,i,e,()=>{r.style.display="none"})}function br(r,e=400){qr(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]};Vr(r,i,e)}function aa(r,e=400){let t=r.getBoundingClientRect().height,n=getComputedStyle(r),o=n.getPropertyValue("padding-top"),s=n.getPropertyValue("padding-bottom");return()=>{qr(r);let i=r.getBoundingClientRect().height,a=getComputedStyle(r),l=a.getPropertyValue("padding-top"),c=a.getPropertyValue("padding-bottom"),u={height:[`${t}px`,`${i}px`],overflow:["hidden","hidden"],paddingTop:[o,l],paddingBottom:[s,c]};Vr(r,u,e)}}function Vr(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),Rn.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),Rn.set(r,s)},15)}function qr(r){Rn.has(r)&&Rn.get(r)()}var Pn=class extends V{setup(){this.list=this.$refs.list,this.toggle=this.$refs.toggle,this.isOpen=this.toggle.classList.contains("open"),this.toggle.addEventListener("click",this.click.bind(this))}open(){this.toggle.classList.add("open"),this.toggle.setAttribute("aria-expanded","true"),br(this.list,180),this.isOpen=!0}close(){this.toggle.classList.remove("open"),this.toggle.setAttribute("aria-expanded","false"),yr(this.list,180),this.isOpen=!1}click(e){e.preventDefault(),this.isOpen?this.close():this.open()}};var Mn=class extends V{setup(){this.container=this.$refs.container,this.popup=this.$el,this.editorInput=this.$refs.editor,this.languageButtons=this.$manyRefs.languageButton,this.languageOptionsContainer=this.$refs.languageOptionsContainer,this.saveButton=this.$refs.saveButton,this.languageInput=this.$refs.languageInput,this.historyDropDown=this.$refs.historyDropDown,this.historyList=this.$refs.historyList,this.favourites=new Set(this.$opts.favourites.split(",")),this.callback=null,this.editor=null,this.history={},this.historyKey="code_history",this.setupListeners(),this.setupFavourites()}setupListeners(){this.container.addEventListener("keydown",e=>{e.ctrlKey&&e.key==="Enter"&&this.save()}),Ne(this.languageButtons,e=>{let t=e.target.dataset.lang;this.languageInput.value=t,this.languageInputChange(t)}),an(this.languageInput,e=>this.save()),this.languageInput.addEventListener("input",e=>this.languageInputChange(this.languageInput.value)),Ne(this.saveButton,e=>this.save()),Ve(this.historyList,"button","click",(e,t)=>{e.preventDefault();let n=t.dataset.time;this.editor&&this.editor.setValue(this.history[n])})}setupFavourites(){for(let e of this.languageButtons)this.setupFavouritesForButton(e);this.sortLanguageList()}setupFavouritesForButton(e){let t=e.dataset.lang,n=this.favourites.has(t);e.setAttribute("data-favourite",n?"true":"false"),Ve(e.parentElement,".lang-option-favorite-toggle","click",()=>{n=!n,n?this.favourites.add(t):this.favourites.delete(t),e.setAttribute("data-favourite",n?"true":"false"),window.$http.patch("/preferences/update-code-language-favourite",{language:t,active:n}),this.sortLanguageList(),n&&e.scrollIntoView({block:"center",behavior:"smooth"})})}sortLanguageList(){let e=this.languageButtons.sort((t,n)=>{let o=t.dataset.favourite==="true",s=n.dataset.favourite==="true";return o&&!s?-1:s&&!o||t.dataset.lang>n.dataset.lang?1:-1}).map(t=>t.parentElement);for(let t of e)this.languageOptionsContainer.append(t)}save(){this.callback&&this.callback(this.editor.getValue(),this.languageInput.value),this.hide()}open(e,t,n){this.languageInput.value=t,this.callback=n,this.show().then(()=>this.languageInputChange(t)).then(()=>window.importVersioned("code")).then(o=>o.setContent(this.editor,e))}async show(){let e=await window.importVersioned("code");this.editor||(this.editor=e.popupEditor(this.editorInput,this.languageInput.value)),this.loadHistory(),this.getPopup().show(()=>{e.updateLayout(this.editor),this.editor.focus()},()=>{this.addHistory()})}hide(){this.getPopup().hide(),this.addHistory()}getPopup(){return window.$components.firstOnElement(this.popup,"popup")}async updateEditorMode(e){(await window.importVersioned("code")).setMode(this.editor,e,this.editor.getValue())}languageInputChange(e){this.updateEditorMode(e);let t=e.toLowerCase();for(let n of this.languageButtons){let o=n.dataset.lang.toLowerCase().trim(),s=t===o;n.classList.toggle("active",s),s&&n.scrollIntoView({block:"center",behavior:"smooth"})}}loadHistory(){this.history=JSON.parse(window.sessionStorage.getItem(this.historyKey)||"{}");let e=Object.keys(this.history).reverse();this.historyDropDown.classList.toggle("hidden",e.length===0),this.historyList.innerHTML=e.map(t=>{let n=new Date(parseInt(t)).toLocaleTimeString();return`<li><button type="button" data-time="${t}" class="text-item">${n}</button></li>`}).join("")}addHistory(){if(!this.editor)return;let e=this.editor.getValue();if(!e)return;let t=Object.keys(this.history).pop();if(this.history[t]===e)return;this.history[String(Date.now())]=e;let n=JSON.stringify(this.history);window.sessionStorage.setItem(this.historyKey,n)}};var $n=class extends V{setup(){let e=this.$el;e.querySelectorAll("pre").length>0&&window.importVersioned("code").then(n=>{n.highlightWithin(e)})}};var Bn=class extends V{async setup(){let e=this.$opts.mode;(await window.importVersioned("code")).inlineEditor(this.$el,e)}};var _n=class extends V{setup(){this.container=this.$el,this.trigger=this.$refs.trigger,this.content=this.$refs.content,this.trigger&&(this.trigger.addEventListener("click",this.toggle.bind(this)),this.openIfContainsError())}open(){this.container.classList.add("open"),this.trigger.setAttribute("aria-expanded","true"),br(this.content,300)}close(){this.container.classList.remove("open"),this.trigger.setAttribute("aria-expanded","false"),yr(this.content,300)}toggle(){this.container.classList.contains("open")?this.close():this.open()}openIfContainsError(){this.content.querySelector(".text-neg.text-small")&&this.open()}};var Nn=class extends V{setup(){this.container=this.$el,this.confirmButton=this.$refs.confirm,this.res=null,Ne(this.confirmButton,()=>{this.sendResult(!0),this.getPopup().hide()})}show(){return this.getPopup().show(null,()=>{this.sendResult(!1)}),new Promise((e,t)=>{this.res=e})}getPopup(){return window.$components.firstOnElement(this.container,"popup")}sendResult(e){this.res&&(this.res(e),this.res=null)}};var Un=class extends V{setup(){this.container=this.$el,this.checkbox=this.container.querySelector("input[type=checkbox]"),this.display=this.container.querySelector('[role="checkbox"]'),this.checkbox.addEventListener("change",this.stateChange.bind(this)),this.container.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(e){(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())}toggle(){this.checkbox.checked=!this.checkbox.checked,this.checkbox.dispatchEvent(new Event("change")),this.stateChange()}stateChange(){let e=this.checkbox.checked?"true":"false";this.display.setAttribute("aria-checked",e)}};var zn=class extends V{setup(){this.container=this.$el,this.dealtWith=!1,this.container.addEventListener("toggle",this.onToggle.bind(this))}onToggle(){this.dealtWith||(this.container.querySelector("pre")&&window.importVersioned("code").then(e=>{e.highlightWithin(this.container)}),this.dealtWith=!0)}};var Gr,Fo,Wr,Ro,xr=class{constructor(e,t=null,n=null){io(this,Gr);io(this,Wr);this.containers=[e],this.onEscape=t,this.onEnter=n,e.addEventListener("keydown",Dr(this,Gr,Fo).bind(this))}shareHandlingToEl(e){this.containers.push(e),e.addEventListener("keydown",Dr(this,Gr,Fo).bind(this))}focusNext(){let e=Dr(this,Wr,Ro).call(this),n=e.indexOf(document.activeElement)+1;n>=e.length&&(n=0),e[n].focus()}focusPrevious(){let e=Dr(this,Wr,Ro).call(this),n=e.indexOf(document.activeElement)-1;n<0&&(n=e.length-1),e[n].focus()}};Gr=new WeakSet,Fo=function(e){e.target.matches("input")&&(e.key==="ArrowRight"||e.key==="ArrowLeft")||(e.key==="ArrowDown"||e.key==="ArrowRight"?(this.focusNext(),e.preventDefault()):e.key==="ArrowUp"||e.key==="ArrowLeft"?(this.focusPrevious(),e.preventDefault()):e.key==="Escape"?this.onEscape?this.onEscape(e):document.activeElement&&document.activeElement.blur():e.key==="Enter"&&this.onEnter&&this.onEnter(e))},Wr=new WeakSet,Ro=function(){let e=[],t='[tabindex]:not([tabindex="-1"]),[href],button:not([tabindex="-1"]),input:not([type=hidden])';for(let n of this.containers)e.push(...n.querySelectorAll(t));return e};var Hn=class extends V{setup(){this.container=this.$el,this.menu=this.$refs.menu,this.toggle=this.$refs.toggle,this.moveMenu=this.$opts.moveMenu,this.bubbleEscapes=this.$opts.bubbleEscapes==="true",this.direction=document.dir==="rtl"?"right":"left",this.body=document.body,this.showing=!1,this.hide=this.hide.bind(this),this.setupListeners()}show(e=null){this.hideAll(),this.menu.style.display="block",this.menu.classList.add("anim","menuIn"),this.toggle.setAttribute("aria-expanded","true");let t=this.menu.getBoundingClientRect(),n=0,o=this.toggle.getBoundingClientRect().height,s=t.bottom>window.innerHeight;this.moveMenu&&(this.body.appendChild(this.menu),this.menu.style.position="fixed",this.menu.style.width=`${t.width}px`,this.menu.style.left=`${t.left}px`,n=s?window.innerHeight-t.top-o/2:t.top),s?(this.menu.style.top="initial",this.menu.style.bottom=`${n}px`):(this.menu.style.top=`${n}px`,this.menu.style.bottom="initial"),this.menu.addEventListener("mouseleave",this.hide),window.addEventListener("click",l=>{this.menu.contains(l.target)||this.hide()});let i=this.menu.querySelector("input");i!==null&&i.focus(),this.showing=!0;let a=new Event("show");this.container.dispatchEvent(a),e&&e.stopPropagation()}hideAll(){for(let e of window.$components.get("dropdown"))e.hide()}hide(){this.menu.style.display="none",this.menu.classList.remove("anim","menuIn"),this.toggle.setAttribute("aria-expanded","false"),this.menu.style.top="",this.menu.style.bottom="",this.moveMenu&&(this.menu.style.position="",this.menu.style[this.direction]="",this.menu.style.width="",this.menu.style.left="",this.container.appendChild(this.menu)),this.showing=!1}setupListeners(){let e=new xr(this.container,t=>{this.hide(),this.toggle.focus(),this.bubbleEscapes||t.stopPropagation()},t=>{t.target.nodeName==="INPUT"&&(t.preventDefault(),t.stopPropagation()),this.hide()});this.moveMenu&&e.shareHandlingToEl(this.menu),this.container.addEventListener("click",t=>{Array.from(this.menu.querySelectorAll("a")).includes(t.target)&&this.hide()}),Ne(this.toggle,t=>{t.stopPropagation(),this.show(t),t instanceof KeyboardEvent&&e.focusNext()})}};var jn=class extends V{setup(){this.elem=this.$el,this.searchInput=this.$refs.searchInput,this.loadingElem=this.$refs.loading,this.listContainerElem=this.$refs.listContainer,this.localSearchSelector=this.$opts.localSearchSelector,this.url=this.$opts.url,this.elem.addEventListener("show",this.onShow.bind(this)),this.searchInput.addEventListener("input",this.onSearch.bind(this)),this.runAjaxSearch=Ft(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=aa(this.listContainerElem,80);this.listContainerElem.innerHTML=t.data,n()}catch(t){console.error(t)}this.toggleLoading(!1),this.localSearchSelector&&this.onSearch()}getAjaxUrl(e=null){if(!e)return this.url;let t=this.url.includes("?")?"&":"?";return`${this.url}${t}search=${encodeURIComponent(e)}`}toggleLoading(e=!1){this.loadingElem.style.display=e?"block":"none"}};var ca=rn(la());var qn=class extends V{setup(){this.container=this.$el,this.url=this.$opts.url,this.successMessage=this.$opts.successMessage,this.removeMessage=this.$opts.removeMessage,this.uploadLimit=Number(this.$opts.uploadLimit),this.uploadLimitMessage=this.$opts.uploadLimitMessage,this.timeoutMessage=this.$opts.timeoutMessage;let e=this;this.dz=new ca.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),On(e.previewElement,800,()=>{this.dz.removeFile(e)})}onError(e,t,n){this.$emit("error",{file:e,errorMessage:t,xhr:n});let o=s=>{let i=e.previewElement.querySelector("[data-dz-errormessage]");i.textContent=s};n&&n.status===413?o(this.uploadLimitMessage):t.file&&o(t.file)}removeAll(){this.dz.removeAllFiles(!0)}};var Gn=class extends V{setup(){this.container=this.$el,this.buttons=this.$manyRefs.tabButton,this.contentElements=this.$manyRefs.tabContent,this.toggleButton=this.$refs.toggle,this.setupListeners(),this.setActiveTab(this.contentElements[0].dataset.tabContent)}setupListeners(){this.toggleButton.addEventListener("click",()=>this.toggle()),this.container.addEventListener("click",e=>{let t=e.target.closest("button");if(this.buttons.includes(t)){let n=t.dataset.tab;this.setActiveTab(n,!0)}})}toggle(){this.container.classList.toggle("open");let e=this.container.classList.contains("open")?"true":"false";this.toggleButton.setAttribute("aria-expanded",e)}setActiveTab(e,t=!1){for(let n of this.buttons)n.classList.remove("active"),n.dataset.tab===e&&n.classList.add("active");for(let n of this.contentElements)n.style.display="none",n.dataset.tabContent===e&&(n.style.display="block");t&&!this.container.classList.contains("open")&&this.toggle()}};var Wn=class extends V{setup(){this.container=this.$el,this.entityType=this.$opts.entityType,this.everyoneInheritToggle=this.$refs.everyoneInherit,this.roleSelect=this.$refs.roleSelect,this.roleContainer=this.$refs.roleContainer,this.setupListeners()}setupListeners(){this.everyoneInheritToggle.addEventListener("change",e=>{let t=e.target.checked,n=document.querySelectorAll('input[name^="permissions[0]["]');for(let o of n)o.disabled=t,o.checked=!1}),this.container.addEventListener("click",e=>{let t=e.target.closest("button");t&&t.dataset.roleId&&this.removeRowOnButtonClick(t)}),this.roleSelect.addEventListener("change",e=>{let t=this.roleSelect.value;t&&this.addRoleRow(t)})}async addRoleRow(e){this.roleSelect.disabled=!0;let t=this.roleSelect.querySelector(`option[value="${e}"]`);t&&t.remove();let n=await window.$http.get(`/permissions/form-row/${this.entityType}/${e}`),o=Kt(n.data);this.roleContainer.append(o),this.roleSelect.disabled=!1}removeRowOnButtonClick(e){let t=e.closest(".item-list-row"),n=e.dataset.roleId,o=e.dataset.roleName,s=document.createElement("option");s.value=n,s.textContent=o,this.roleSelect.append(s),t.remove()}};var Yn=class extends V{setup(){this.entityId=this.$opts.entityId,this.entityType=this.$opts.entityType,this.contentView=this.$refs.contentView,this.searchView=this.$refs.searchView,this.searchResults=this.$refs.searchResults,this.searchInput=this.$refs.searchInput,this.searchForm=this.$refs.searchForm,this.clearButton=this.$refs.clearButton,this.loadingBlock=this.$refs.loadingBlock,this.setupListeners()}setupListeners(){this.searchInput.addEventListener("change",this.runSearch.bind(this)),this.searchForm.addEventListener("submit",e=>{e.preventDefault(),this.runSearch()}),Ne(this.clearButton,this.clearSearch.bind(this))}runSearch(){let e=this.searchInput.value.trim();if(e.length===0)return this.clearSearch();this.searchView.classList.remove("hidden"),this.contentView.classList.add("hidden"),this.loadingBlock.classList.remove("hidden");let t=window.baseUrl(`/search/${this.entityType}/${this.entityId}`);window.$http.get(t,{term:e}).then(n=>{this.searchResults.innerHTML=n.data}).catch(console.error).then(()=>{this.loadingBlock.classList.add("hidden")})}clearSearch(){this.searchView.classList.add("hidden"),this.contentView.classList.remove("hidden"),this.loadingBlock.classList.add("hidden"),this.searchInput.value=""}};var Kn=class extends V{setup(){this.elem=this.$el,this.entityTypes=this.$opts.entityTypes||"page,book,chapter",this.entityPermission=this.$opts.entityPermission||"view",this.input=this.$refs.input,this.searchInput=this.$refs.search,this.loading=this.$refs.loading,this.resultsContainer=this.$refs.results,this.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())}),Ve(this.$el,"[data-entity-type]","keydown",(t,n)=>{if(t.ctrlKey&&t.code==="Enter"){let o=this.$el.closest("form");if(o){o.submit(),t.preventDefault();return}}t.code==="ArrowDown"&&this.focusAdjacent(!0),t.code==="ArrowUp"&&this.focusAdjacent(!1)}),this.searchInput.addEventListener("keydown",t=>{t.code==="ArrowDown"&&this.focusAdjacent(!0)})}focusAdjacent(e=!0){let t=Array.from(this.resultsContainer.querySelectorAll("[data-entity-type]")),n=t.indexOf(document.activeElement),o=t[n+(e?1:-1)]||t[0];o&&o.focus()}reset(){this.searchInput.value="",this.showLoading(),this.initialLoad()}focusSearch(){this.searchInput.focus()}showLoading(){this.loading.style.display="block",this.resultsContainer.style.display="none"}hideLoading(){this.loading.style.display="none",this.resultsContainer.style.display="block"}initialLoad(){window.$http.get(this.searchUrl()).then(e=>{this.resultsContainer.innerHTML=e.data,this.hideLoading()})}searchUrl(){return`/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`}searchEntities(e){this.input.value="";let t=`${this.searchUrl()}&term=${encodeURIComponent(e)}`;window.$http.get(t).then(n=>{this.resultsContainer.innerHTML=n.data,this.hideLoading()})}isDoubleClick(){let e=Date.now(),t=e-this.lastClick<300;return this.lastClick=e,t}onClick(e){let t=e.target.closest("[data-entity-type]");t&&(e.preventDefault(),e.stopPropagation(),this.selectItem(t))}selectItem(e){let t=this.isDoubleClick(),n=e.getAttribute("data-entity-type"),o=e.getAttribute("data-entity-id"),s=!e.classList.contains("selected")||t;this.unselectAll(),this.input.value=s?`${n}:${o}`:"";let i=e.getAttribute("href"),a=e.querySelector(".entity-list-item-name").textContent,l={id:Number(o),name:a,link:i};s?(e.classList.add("selected"),this.selectedItemData=l):window.$events.emit("entity-select-change",null),!(!t&&!s)&&(t&&this.confirmSelection(l),s&&window.$events.emit("entity-select-change",l))}confirmSelection(e){window.$events.emit("entity-select-confirm",e)}unselectAll(){let e=this.elem.querySelectorAll(".selected");for(let t of e)t.classList.remove("selected","primary-background");this.selectedItemData=null}};var Xn=class extends V{setup(){this.container=this.$el,this.selectButton=this.$refs.select,this.selectorEl=this.$refs.selector,this.callback=null,this.selection=null,this.selectButton.addEventListener("click",this.onSelectButtonClick.bind(this)),window.$events.listen("entity-select-change",this.onSelectionChange.bind(this)),window.$events.listen("entity-select-confirm",this.handleConfirmedSelection.bind(this))}show(e){this.callback=e,this.getPopup().show(),this.getSelector().focusSearch()}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.container,"popup")}getSelector(){return window.$components.firstOnElement(this.selectorEl,"entity-selector")}onSelectButtonClick(){this.handleConfirmedSelection(this.selection)}onSelectionChange(e){this.selection=e,e===null?this.selectButton.setAttribute("disabled","true"):this.selectButton.removeAttribute("disabled")}handleConfirmedSelection(e){this.hide(),this.getSelector().reset(),this.callback&&e&&this.callback(e)}};var Zn=class extends V{setup(){this.container=this.$el,this.name=this.$opts.name,Ne(this.$el,()=>{this.$emit(this.name,this.$opts)})}};var Qn=class extends V{setup(e){this.targetSelector=this.$opts.targetSelector,this.isOpen=this.$opts.isOpen==="true",this.updateEndpoint=this.$opts.updateEndpoint,this.$el.addEventListener("click",this.click.bind(this))}open(e){br(e,200)}close(e){yr(e,200)}click(e){e.preventDefault();let t=document.querySelectorAll(this.targetSelector);for(let n of t)this.isOpen?this.close(n):this.open(n);this.isOpen=!this.isOpen,this.updateSystemAjax(this.isOpen)}updateSystemAjax(e){window.$http.patch(this.updateEndpoint,{expand:e?"true":"false"})}};var Jn=class extends V{setup(){this.container=this.$el,this.input=this.$refs.input,this.suggestions=this.$refs.suggestions,this.suggestionResultsWrap=this.$refs.suggestionResults,this.loadingWrap=this.$refs.loading,this.button=this.$refs.button,this.setupListeners()}setupListeners(){let e=Ft(this.updateSuggestions.bind(this),200,!1);this.input.addEventListener("input",()=>{let t=this.input.value;t.length>0?(this.loadingWrap.style.display="block",this.suggestionResultsWrap.style.opacity="0.5",e(t)):this.hideSuggestions()}),this.input.addEventListener("dblclick",()=>{this.input.setAttribute("autocomplete","on"),this.button.focus(),this.input.focus()}),new xr(this.container,()=>{this.hideSuggestions()})}async updateSuggestions(e){let{data:t}=await window.$http.get("/search/suggest",{term:e});if(!this.input.value)return;let n=Kt(t);this.suggestionResultsWrap.innerHTML="",this.suggestionResultsWrap.style.opacity="1",this.loadingWrap.style.display="none",this.suggestionResultsWrap.append(n),this.container.classList.contains("search-active")||this.showSuggestions()}showSuggestions(){this.container.classList.add("search-active"),window.requestAnimationFrame(()=>{this.suggestions.classList.add("search-suggestions-animation")})}hideSuggestions(){this.container.classList.remove("search-active"),this.suggestions.classList.remove("search-suggestions-animation"),this.suggestionResultsWrap.innerHTML=""}};var ei=class extends V{setup(){this.elem=this.$el,this.toggleButton=this.$refs.toggle,this.menu=this.$refs.menu,this.open=!1,this.toggleButton.addEventListener("click",this.onToggle.bind(this)),this.onWindowClick=this.onWindowClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this)}onToggle(e){this.open=!this.open,this.menu.classList.toggle("show",this.open),this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open?(this.elem.addEventListener("keydown",this.onKeyDown),window.addEventListener("click",this.onWindowClick)):(this.elem.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("click",this.onWindowClick)),e.stopPropagation()}onKeyDown(e){e.code==="Escape"&&this.onToggle(e)}onWindowClick(e){this.onToggle(e)}};var ti=class extends V{setup(){this.uploadedTo=this.$opts.uploadedTo,this.container=this.$el,this.popupEl=this.$refs.popup,this.searchForm=this.$refs.searchForm,this.searchInput=this.$refs.searchInput,this.cancelSearch=this.$refs.cancelSearch,this.listContainer=this.$refs.listContainer,this.filterTabs=this.$manyRefs.filterTabs,this.selectButton=this.$refs.selectButton,this.formContainer=this.$refs.formContainer,this.dropzoneContainer=this.$refs.dropzoneContainer,this.type="gallery",this.lastSelected={},this.lastSelectedTime=0,this.callback=null,this.resetState=()=>{this.hasData=!1,this.page=1,this.filter="all"},this.resetState(),this.setupListeners()}setupListeners(){Ne(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()}),Ne(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())}),Ve(this.listContainer,".load-more","click",async e=>{Rr(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),Ne(this.selectButton,()=>{this.callback&&this.callback(this.lastSelected),this.hide()}),Ve(this.formContainer,"#image-manager-delete","click",e=>{this.lastSelected&&this.loadImageEditForm(this.lastSelected.id,!0)}),this.formContainer.addEventListener("ajax-form-success",this.refreshGallery.bind(this)),this.container.addEventListener("dropzone-success",this.refreshGallery.bind(this))}show(e,t="gallery"){this.resetAll(),this.callback=e,this.type=t,this.getPopup().show(),this.dropzoneContainer.classList.toggle("hidden",t!=="gallery"),this.hasData||(this.loadGallery(),this.hasData=!0)}hide(){this.getPopup().hide()}getPopup(){return window.$components.firstOnElement(this.popupEl,"popup")}async loadGallery(){let e={page:this.page,search:this.searchInput.value||null,uploaded_to:this.uploadedTo,filter_type:this.filter==="all"?null:this.filter},{data:t}=await window.$http.get(`images/${this.type}`,e);e.page===1&&(this.listContainer.innerHTML=""),this.addReturnedHtmlElementsToList(t),Ps(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(){Rr(this.listContainer),this.page=1}refreshGallery(){this.resetListView(),this.loadGallery()}onImageSelectEvent(e){let t=JSON.parse(e.detail.data),n=t&&t.id===this.lastSelected.id&&Date.now()-this.lastSelectedTime<400,o=e.target.classList.contains("selected");[...this.listContainer.querySelectorAll(".selected")].forEach(s=>{s.classList.remove("selected")}),o?this.resetEditForm():(e.target.classList.add("selected"),this.loadImageEditForm(t.id)),this.selectButton.classList.toggle("hidden",o),n&&this.callback&&(this.callback(t),this.hide()),this.lastSelected=t,this.lastSelectedTime=Date.now()}async loadImageEditForm(e,t=!1){t||(this.formContainer.innerHTML="");let n=t?{delete:!0}:{},{data:o}=await window.$http.get(`/images/edit/${e}`,n);this.formContainer.innerHTML=o,window.$components.init(this.formContainer)}};var ri=class extends V{setup(){this.imageElem=this.$refs.image,this.imageInput=this.$refs.imageInput,this.resetInput=this.$refs.resetInput,this.removeInput=this.$refs.removeInput,this.resetButton=this.$refs.resetButton,this.removeButton=this.$refs.removeButton||null,this.defaultImage=this.$opts.defaultImage,this.setupListeners()}setupListeners(){this.resetButton.addEventListener("click",this.reset.bind(this)),this.removeButton&&this.removeButton.addEventListener("click",this.removeImage.bind(this)),this.imageInput.addEventListener("change",this.fileInputChange.bind(this))}fileInputChange(){this.resetInput.setAttribute("disabled","disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled");for(let e of this.imageInput.files)this.imageElem.src=window.URL.createObjectURL(e);this.imageElem.classList.remove("none")}reset(){this.imageInput.value="",this.imageElem.src=this.defaultImage,this.resetInput.removeAttribute("disabled"),this.removeInput&&this.removeInput.setAttribute("disabled","disabled"),this.imageElem.classList.remove("none")}removeImage(){this.imageInput.value="",this.imageElem.classList.add("none"),this.removeInput.removeAttribute("disabled"),this.resetInput.setAttribute("disabled","disabled")}};var ni=class extends V{setup(){this.elem=this.$el,this.menu=this.$refs.menu,this.sortInput=this.$refs.sort,this.orderInput=this.$refs.order,this.form=this.$refs.form,this.setupListeners()}setupListeners(){this.menu.addEventListener("click",e=>{e.target.closest("[data-sort-value]")!==null&&this.sortOptionClick(e)}),this.elem.addEventListener("click",e=>{e.target.closest("[data-sort-dir]")!==null&&this.sortDirectionClick(e)})}sortOptionClick(e){let t=e.target.closest("[data-sort-value]");this.sortInput.value=t.getAttribute("data-sort-value"),e.preventDefault(),this.form.submit()}sortDirectionClick(e){let t=this.orderInput.value;this.orderInput.value=t==="asc"?"desc":"asc",e.preventDefault(),this.form.submit()}};var wu=rn(mu()),Eu=rn(xu()),yi=class{constructor(){this.renderer=new wu.default({html:!0}),this.renderer.use(Eu.default,{label:!0})}getRenderer(){return this.renderer}render(e){return this.renderer.render(e)}};function Sp(r,e){return document.createElement(r,e)}function Ap(r,e,t){return document.createElementNS(r,e,t)}function kp(){return document.createDocumentFragment()}function Tp(r){return document.createTextNode(r)}function Ip(r){return document.createComment(r)}function Dp(r,e,t){r.insertBefore(e,t)}function Lp(r,e){r.removeChild(e)}function Fp(r,e){r.appendChild(e)}function Rp(r){return r.parentNode}function Op(r){return r.nextSibling}function Pp(r){return r.tagName}function Mp(r,e){r.textContent=e}function $p(r){return r.textContent}function Bp(r){return r.nodeType===1}function _p(r){return r.nodeType===3}function Np(r){return r.nodeType===8}function Up(r){return r.nodeType===11}var bi={createElement:Sp,createElementNS:Ap,createTextNode:Tp,createDocumentFragment:kp,createComment:Ip,insertBefore:Dp,removeChild:Lp,appendChild:Fp,parentNode:Rp,nextSibling:Op,tagName:Pp,setTextContent:Mp,getTextContent:$p,isElement:Bp,isText:_p,isComment:Np,isDocumentFragment:Up};function Gt(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 Cu=Array.isArray;function Su(r){return typeof r=="string"||typeof r=="number"||r instanceof String||r instanceof Number}function us(r){return r===void 0}function mt(r){return r!==void 0}var ds=Gt("",{},[],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 Hp(){throw new Error("The document fragment is not supported on this platform.")}function jp(r,e){return r.isElement(e)}function Vp(r,e){return r.isDocumentFragment(e)}function qp(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 Gp=["create","update","remove","destroy","pre","post"];function hs(r,e,t){let n={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},o=e!==void 0?e:bi;for(let p of Gp)for(let v of r){let y=v[p];y!==void 0&&n[p].push(y)}function s(p){let v=p.id?"#"+p.id:"",y=p.getAttribute("class"),b=y?"."+y.split(" ").join("."):"";return Gt(o.tagName(p).toLowerCase()+v+b,{},[],void 0,p)}function i(p){return Gt(void 0,{},[],void 0,p)}function a(p,v){return function(){if(--v===0){let b=o.parentNode(p);o.removeChild(b,p)}}}function l(p,v){var y,b,x,I;let C,M=p.data;if(M!==void 0){let A=(y=M.hook)===null||y===void 0?void 0:y.init;mt(A)&&(A(p),M=p.data)}let S=p.children,O=p.sel;if(O==="!")us(p.text)&&(p.text=""),p.elm=o.createComment(p.text);else if(O!==void 0){let A=O.indexOf("#"),D=O.indexOf(".",A),T=A>0?A:O.length,P=D>0?D:O.length,B=A!==-1||D!==-1?O.slice(0,Math.min(T,P)):O,_=p.elm=mt(M)&&mt(C=M.ns)?o.createElementNS(C,B,M):o.createElement(B,M);for(T<P&&_.setAttribute("id",O.slice(T+1,P)),D>0&&_.setAttribute("class",O.slice(P+1).replace(/\./g," ")),C=0;C<n.create.length;++C)n.create[C](ds,p);if(Cu(S))for(C=0;C<S.length;++C){let Q=S[C];Q!=null&&o.appendChild(_,l(Q,v))}else Su(p.text)&&o.appendChild(_,o.createTextNode(p.text));let j=p.data.hook;mt(j)&&((b=j.create)===null||b===void 0||b.call(j,ds,p),j.insert&&v.push(p))}else if(((x=t?.experimental)===null||x===void 0?void 0:x.fragments)&&p.children){let A=p.children;for(p.elm=((I=o.createDocumentFragment)!==null&&I!==void 0?I:Hp)(),C=0;C<n.create.length;++C)n.create[C](ds,p);for(C=0;C<A.length;++C){let D=A[C];D!=null&&o.appendChild(p.elm,l(D,v))}}else p.elm=o.createTextNode(p.text);return p.elm}function c(p,v,y,b,x,I){for(;b<=x;++b){let C=y[b];C!=null&&o.insertBefore(p,l(C,I),v)}}function u(p){var v,y;let b=p.data;if(b!==void 0){(y=(v=b?.hook)===null||v===void 0?void 0:v.destroy)===null||y===void 0||y.call(v,p);for(let x=0;x<n.destroy.length;++x)n.destroy[x](p);if(p.children!==void 0)for(let x=0;x<p.children.length;++x){let I=p.children[x];I!=null&&typeof I!="string"&&u(I)}}}function d(p,v,y,b){for(var x,I;y<=b;++y){let C,M,S=v[y];if(S!=null)if(mt(S.sel)){u(S),C=n.remove.length+1,M=a(S.elm,C);for(let A=0;A<n.remove.length;++A)n.remove[A](S,M);let O=(I=(x=S?.data)===null||x===void 0?void 0:x.hook)===null||I===void 0?void 0:I.remove;mt(O)?O(S,M):M()}else o.removeChild(p,S.elm)}}function h(p,v,y,b){let x=0,I=0,C=v.length-1,M=v[0],S=v[C],O=y.length-1,A=y[0],D=y[O],T,P,B,_;for(;x<=C&&I<=O;)M==null?M=v[++x]:S==null?S=v[--C]:A==null?A=y[++I]:D==null?D=y[--O]:Qr(M,A)?(f(M,A,b),M=v[++x],A=y[++I]):Qr(S,D)?(f(S,D,b),S=v[--C],D=y[--O]):Qr(M,D)?(f(M,D,b),o.insertBefore(p,M.elm,o.nextSibling(S.elm)),M=v[++x],D=y[--O]):Qr(S,A)?(f(S,A,b),o.insertBefore(p,S.elm,M.elm),S=v[--C],A=y[++I]):(T===void 0&&(T=qp(v,x,C)),P=T[A.key],us(P)?o.insertBefore(p,l(A,b),M.elm):(B=v[P],B.sel!==A.sel?o.insertBefore(p,l(A,b),M.elm):(f(B,A,b),v[P]=void 0,o.insertBefore(p,B.elm,M.elm))),A=y[++I]);I<=O&&(_=y[O+1]==null?null:y[O+1].elm,c(p,_,y,I,O,b)),x<=C&&d(p,v,x,C)}function f(p,v,y){var b,x,I,C,M,S,O,A;let D=(b=v.data)===null||b===void 0?void 0:b.hook;(x=D?.prepatch)===null||x===void 0||x.call(D,p,v);let T=v.elm=p.elm,P=p.children,B=v.children;if(p!==v){if(v.data!==void 0||mt(v.text)&&v.text!==p.text){(I=v.data)!==null&&I!==void 0||(v.data={}),(C=p.data)!==null&&C!==void 0||(p.data={});for(let _=0;_<n.update.length;++_)n.update[_](p,v);(O=(S=(M=v.data)===null||M===void 0?void 0:M.hook)===null||S===void 0?void 0:S.update)===null||O===void 0||O.call(S,p,v)}us(v.text)?mt(P)&&mt(B)?P!==B&&h(T,P,B,y):mt(B)?(mt(p.text)&&o.setTextContent(T,""),c(T,null,B,0,B.length-1,y)):mt(P)?d(T,P,0,P.length-1):mt(p.text)&&o.setTextContent(T,""):p.text!==v.text&&(mt(P)&&d(T,P,0,P.length-1),o.setTextContent(T,v.text)),(A=D?.postpatch)===null||A===void 0||A.call(D,p,v)}}return function(v,y){let b,x,I,C=[];for(b=0;b<n.pre.length;++b)n.pre[b]();for(jp(o,v)?v=s(v):Vp(o,v)&&(v=i(v)),Qr(v,y)?f(v,y,C):(x=v.elm,I=o.parentNode(x),l(y,C),I!==null&&(o.insertBefore(I,y.elm,o.nextSibling(x)),d(I,[v],0,0))),b=0;b<C.length;++b)C[b].data.hook.insert(C[b]);for(b=0;b<n.post.length;++b)n.post[b]();return y}}function fs(r,e,t){if(r.ns="http://www.w3.org/2000/svg",t!=="foreignObject"&&e!==void 0)for(let n=0;n<e.length;++n){let o=e[n];if(typeof o=="string")continue;let s=o.data;s!==void 0&&fs(s,o.children,o.sel)}}function Jr(r,e){let t=e!==void 0?e:bi,n;if(t.isElement(r)){let o=r.id?"#"+r.id:"",s=r.getAttribute("class"),i=s?"."+s.split(" ").join("."):"",a=t.tagName(r).toLowerCase()+o+i,l={},c={},u={},d=[],h,f,p,v=r.attributes,y=r.childNodes;for(f=0,p=v.length;f<p;f++)h=v[f].nodeName,h[0]==="d"&&h[1]==="a"&&h[2]==="t"&&h[3]==="a"&&h[4]==="-"?c[h.slice(5)]=v[f].nodeValue||"":h!=="id"&&h!=="class"&&(l[h]=v[f].nodeValue);for(f=0,p=y.length;f<p;f++)d.push(Jr(y[f],e));return Object.keys(l).length>0&&(u.attrs=l),Object.keys(c).length>0&&(u.datasets=c),a[0]==="s"&&a[1]==="v"&&a[2]==="g"&&(a.length===3||a[3]==="."||a[3]==="#")&&fs(u,d,a),Gt(a,u,d,void 0,r)}else return t.isText(r)?(n=t.getTextContent(r),Gt(void 0,void 0,void 0,n,r)):t.isComment(r)?(n=t.getTextContent(r),Gt("!",{},[],n,r)):Gt("",{},[],void 0,r)}var Wp="http://www.w3.org/1999/xlink",Yp="http://www.w3.org/XML/1998/namespace";function Au(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(Yp,t,i):t.charCodeAt(5)===58?n.setAttributeNS(Wp,t,i):n.setAttribute(t,i))}for(t in o)t in s||n.removeAttribute(t)}}var ps={create:Au,update:Au};var xi;function Kp(){return xi||(xi=hs([ps]),xi)}function ku(r,e){let t=document.createElement("div");t.innerHTML=e,Kp()(Jr(r),Jr(t))}var wi=class{constructor(e){this.editor=e,this.container=e.config.displayEl,this.doc=null,this.lastDisplayClick=0,this.container.contentDocument.readyState==="complete"?this.onLoad():this.container.addEventListener("load",this.onLoad.bind(this)),this.updateVisibility(e.settings.get("showPreview")),e.settings.onChange("showPreview",t=>this.updateVisibility(t))}updateVisibility(e){let t=this.container.closest(".markdown-editor-wrap");t.style.display=e?null:"none"}onLoad(){this.doc=this.container.contentDocument,this.loadStylesIntoDisplay(),this.doc.body.className="page-content",this.doc.addEventListener("click",this.onDisplayClick.bind(this))}onDisplayClick(e){let t=Date.now()-this.lastDisplayClick<300,n=e.target.closest("a");if(n!==null){e.preventDefault(),window.open(n.getAttribute("href"));return}let o=e.target.closest("[drawio-diagram]");if(o!==null&&t){this.editor.actions.editDrawing(o);return}this.lastDisplayClick=Date.now()}loadStylesIntoDisplay(){this.doc.documentElement.classList.add("markdown-editor-display"),document.documentElement.classList.contains("dark-mode")&&(this.doc.documentElement.style.backgroundColor="#222",this.doc.documentElement.classList.add("dark-mode")),this.doc.head.innerHTML="";let e=document.head.querySelectorAll("style,link[rel=stylesheet]");for(let t of e){let n=t.cloneNode(!0);this.doc.head.appendChild(n)}}patchWithHtml(e){let t=this.doc.body;if(t.children.length===0){let o=document.createElement("div");this.doc.body.append(o)}let n=t.children[0];ku(n,e)}scrollToIndex(e){let t=this.doc.body?.children[0]?.children;if(t&&t.length<=e)return;(e===-1?t[t.length-1]:t[e]).scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}};var _t=null,vs,ms,gs;function Xp(r,e,t){ms=e,gs=t,_t=document.createElement("iframe"),_t.setAttribute("frameborder","0"),window.addEventListener("message",Tu),_t.setAttribute("src",r),_t.setAttribute("class","fullscreen"),_t.style.backgroundColor="#FFFFFF",document.body.appendChild(_t),vs=new URL(r).origin}function Zp(){Iu()}function Tu(r){if(!r.data||r.data.length<1||r.origin!==vs)return;let e=JSON.parse(r.data);e.event==="init"?em():e.event==="exit"?Iu():e.event==="save"?Jp(e):e.event==="export"?Qp(e):e.event==="configure"&&tm()}function Qp(r){gs&&gs(r.data)}function Jp(r){ys({action:"export",format:"xmlpng",xml:r.xml,spin:"Updating drawing"})}function em(){!ms||ms().then(r=>{ys({action:"load",autosave:1,xml:r})})}function tm(){let r={};window.$events.emitPublic(_t,"editor-drawio::configure",{config:r}),ys({action:"configure",config:r})}function Iu(){window.removeEventListener("message",Tu),_t&&document.body.removeChild(_t)}function ys(r){_t.contentWindow.postMessage(JSON.stringify(r),vs)}async function rm(r,e){let t={image:r,uploaded_to:e};return(await window.$http.post(window.baseUrl("/images/drawio"),t)).data}async function nm(r){return`data:image/png;base64,${(await window.$http.get(window.baseUrl(`/images/drawio/base64/${r}`))).data.content}`}var wt={show:Xp,close:Zp,upload:rm,load:nm};var Ei=class{constructor(e){this.editor=e}updateAndRender(){let e=this.editor.cm.getValue();this.editor.config.inputEl.value=e;let t=this.editor.markdown.render(e);window.$events.emit("editor-html-change",t),window.$events.emit("editor-markdown-change",e),this.editor.display.patchWithHtml(t)}insertImage(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{let o=n.thumbs.display||n.url,s=this.editor.cm.getSelection(),i="[]("+n.url+")";this.editor.cm.focus(),this.editor.cm.replaceSelection(i),this.editor.cm.setCursor(e.line,e.ch+i.length)},"gallery")}insertLink(){let e=this.editor.cm.getCursor("from"),t=this.editor.cm.getSelection()||"",n=`[${t}]()`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n);let o=t===""?-3:-1;this.editor.cm.setCursor(e.line,e.ch+n.length+o)}showImageManager(){let e=this.editor.cm.getCursor("from");window.$components.first("image-manager").show(n=>{this.insertDrawing(n,e)},"drawio")}showLinkSelector(){let e=this.editor.cm.getCursor("from");window.$components.first("entity-selector-popup").show(n=>{let s=`[${this.editor.cm.getSelection()||n.name}](${n.link})`;this.editor.cm.focus(),this.editor.cm.replaceSelection(s),this.editor.cm.setCursor(e.line,e.ch+s.length)})}startDrawing(){let e=this.editor.config.drawioUrl;if(!e)return;let t=this.editor.cm.getCursor("from");wt.show(e,()=>Promise.resolve(""),n=>{let o={image:n,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",o).then(s=>{this.insertDrawing(s.data,t),wt.close()}).catch(s=>{this.handleDrawingUploadError(s)})})}insertDrawing(e,t){let n=`<div drawio-diagram="${e.id}"><img src="${e.url}"></div>`;this.editor.cm.focus(),this.editor.cm.replaceSelection(n),this.editor.cm.setCursor(t.line,t.ch+n.length)}editDrawing(e){let t=this.editor.config.drawioUrl;if(!t)return;let n=this.editor.cm.getCursor("from"),o=e.getAttribute("drawio-diagram");wt.show(t,()=>wt.load(o),s=>{let i={image:s,uploaded_to:Number(this.editor.config.pageId)};window.$http.post("/images/drawio",i).then(a=>{let l=`<div drawio-diagram="${a.data.id}"><img src="${a.data.url}"></div>`,c=this.editor.cm.getValue().split(`
`).map(u=>u.indexOf(`drawio-diagram="${o}"`)!==-1?l:u).join(`
`);this.editor.cm.setValue(c),this.editor.cm.setCursor(n),this.editor.cm.focus(),wt.close()}).catch(a=>{this.handleDrawingUploadError(a)})})}handleDrawingUploadError(e){e.status===413?window.$events.emit("error",this.editor.config.text.serverUploadLimit):window.$events.emit("error",this.editor.config.text.imageUploadError),console.log(e)}fullScreen(){let e=this.editor.config.container,t=e.classList.contains("fullscreen");e.classList.toggle("fullscreen",!t),document.body.classList.toggle("markdown-fullscreen",!t)}scrollToText(e){if(!e)return;let n=this.editor.cm.getValue().split(/\r?\n/),o=n.findIndex(s=>s&&s.indexOf(e)!==-1);o!==-1&&(this.editor.cm.scrollIntoView({line:o},200),this.editor.cm.focus(),this.editor.cm.setCursor({line:o,char:n[o].length}))}focus(){this.editor.cm.focus()}insertContent(e){this.editor.cm.replaceSelection(e)}prependContent(e){let t=this.editor.cm.getCursor("from"),n=e+`
`+this.editor.cm.getValue();this.editor.cm.setValue(n);let o=e.split(`