bookstack/public/dist/code.js

31 lines
610 KiB
JavaScript
Raw Normal View History

var j=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=di(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),li.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=di(this,e,t);let n=[];return this.decompose(e,t,n,0),li.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Lt(this),s=new Lt(e);for(let o=t,O=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(O+=r.value.length,r.done||O>=n)return!0}}iter(e=1){return new Lt(this,e)}iterRange(e,t=this.length){return new Yn(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Cn(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new Ze(e):li.from(Ze.split(e,[]))}},Ze=class i extends j{constructor(e,t=zd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],O=r+o.length;if((t?n:O)>=e)return new ns(r,O,n,o);r=O+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i($a(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),O=qn(s.text,o.text.slice(),0,s.length);if(O.length<=32)n.push(new i(O,o.length+s.length));else{let a=O.length>>1;n.push(new i(O.slice(0,a)),new i(O.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=di(this,e,t);let r=qn(this.text,qn(n.text,$a(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):li.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){[e,t]=di(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let O=this.text[o],a=s+O.length;s>e&&o&&(r+=n),e<a&&t>s&&(r+=O.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},li=class i extends j{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],O=r+o.length,a=n+o.lines-1;if((t?a:O)>=e)return o.lineInner(e,t,n,r);r=O+1,n=a+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let O=this.children[s],a=o+O.length;if(e<=a&&t>=o){let l=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!l?n.push(O):O.decompose(e-o,t-o,n,l)}o=a+1}}replace(e,t,n){if([e,t]=di(this,e,t),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],O=s+o.length;if(e>=s&&t<=O){let a=o.replace(e-s,t-s,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let h=this.children.slice();return h[r]=a,new i(h,this.length-(t-e)+n.length)}return super.replace(s,O,a)}s=O+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
`){[e,t]=di(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let O=this.children[s],a=o+O.length;o>e&&s&&(r+=n),e<a&&t>o&&(r+=O.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,O]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==O)return n;let a=this.children[r],l=e.children[s];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Ze(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,O=[],a=0,l=-1,h=[];function c(d){let p;if(d.lines>s&&d instanceof i)for(let m of d.children)c(m);else d.lines>o&&(a>o||!a)?(f(),O.push(d)):d instanceof Ze&&a&&(p=h[h.length-1])instanceof Ze&&d.lines+p.lines<=32?(a+=d.lines,l+=d.length+1,h[h.length-1]=new Ze(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,l+=d.length+1,h.push(d))}function f(){a!=0&&(O.push(h.length==1?h[0]:i.from(h,l)),l=-1,a=h.length=0)}for(let d of e)c(d);return f(),O.length==1?O[0]:new i(O,t)}};j.empty=new Ze([""],0);function zd(i){let e=-1;for(let t of i)e+=t.length+1;return e}function qn(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let O=i[s],a=r+O.length;a>=t&&(a>n&&(O=O.slice(0,n-r)),r<t&&(O=O.slice(t-r)),o?(e[e.length-1]+=O,o=!1):e.push(O)),r=a+1}return e}function $a(i,e,t){return qn(i,[""],e,t)}var Lt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Ze?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,O=r instanceof Ze?r.text.length:r.children.length;if(o==(t>0?O:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof Ze){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Ze?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Yn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Lt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Cn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(j.prototype[Symbol.iterator]=function(){return this.iter()},Lt.prototype[Symbol.iterator]=Yn.prototype[Symbol.iterator]=Cn.prototype[Symbol.iterator]=function(){return this});var ns=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function di(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var hi="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;i<hi.length;i++)hi[i]+=hi[i-1];function Zd(i){for(let e=1;e<hi.length;e+=2)if(hi[e]>i)return hi[e-1]<=i;return!1}function ga(i){return i>=127462&&i<=127487}var Qa=8205;function le(i,e,t=!0,n=!0){return(t?wa:Xd)(i,e,n)}function wa(i,e,t){if(e==i.length)return e;e&&ka(i.charCodeAt(e))&&Ta(i.charCodeAt(e-1))&&e--;let n=ci(i,e);for(e+=ji(n);e<i.length;){let r=ci(i,e);if(n==Qa||r==Qa||t&&Zd(r))e+=ji(r),n=r;else if(ga(r)){let s=0,o=e-2;for(;o>=0&&ga(ci(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Xd(i,e,t){for(;e>0;){let n=wa(i,e-2,t);if(n<e)return n;e--}return 0}function ka(i){return i>=56320&&i<57344}function Ta(i){return i>=55296&&i<56320}function ci(i,e){let t=i.charCodeAt(e);if(!Ta(t)||e+1=
`}get readOnly(){return this.facet(qa)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(Za))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return _d(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,O=e-n;for(;o>0;){let a=le(t,o,!1);if(s(t.slice(a,o))!=Ae.Word)break;o=a}for(;O<r;){let a=le(t,O);if(s(t.slice(O,a))!=Ae.Word)break;O=a}return o==O?null:S.range(o+n,O+n)}};L.allowMultipleSelections=as;L.tabSize=W.define({combine:i=>i.length?i[0]:4});L.lineSeparator=Xa;L.readOnly=qa;L.phrases=W.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});L.languageData=Za;L.changeFilter=Wa;L.transactionFilter=Ra;L.transactionExtender=Va;dt.reconfigure=B.define();function xt(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],O=n[s];if(O===void 0)n[s]=o;else if(!(O===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](O,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var De=class{eq(e){return this==e}range(e,t=e){return _i.create(e,t,this)}};De.prototype.startSide=De.prototype.endSide=0;De.prototype.point=!1;De.prototype.mapMode=ae.TrackDel;var _i=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function us(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var ds=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,O=s.length;;){if(o==O)return o;let a=o+O>>1,l=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return l>=0?o:O;l>=0?O=a:o=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],o=-1,O=-1;for(let a=0;a<this.value.length;a++){let l=this.value[a],h=this.from[a]+e,c=this.to[a]+e,f,d;if(h==c){let p=t.mapPos(h,l.startSide,l.mapMode);if(p==null||(f=d=p,l.startSide!=l.endSide&&(d=t.mapPos(h,l.endSide),d<f)))continue}else if(f=t.mapPos(h,l.startSide),d=t.mapPos(c,l.endSide),f>d||f==d&&l.startSide>0&&l.endSide<=0)continue;(d-f||l.endSide-l.startSide)<0||(o<0&&(o=f),l.point&&(O=Math.max(O,d-f)),n.push(l),r.push(f-o),s.push(d-o))}return{mapped:n.length?new i(r,s,n,O):null,pos:o}}},H=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(us)),this.isEmpty)return t.length?i.of(t):this;let O=new Un(this,null,-1).goto(0),a=0,l=[],h=new Bt;for(;O.value||a<t.length;)if(a<t.length&&(O.from-t[a].from||O.startSide-t[a].value.startSide)>=0){let c=t[a++];h.addInner(c.from,c.to,c.value)||l.push(c)}else O.rangeIndex==1&&O.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(O.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(O.chunkIndex)||s<this.chunkPos[O.chunkIndex])&&h.addChunk(this.chunkPos[O.chunkIndex],this.chunk[O.chunkIndex])?O.nextChunk():((!o||r>O.to||s<O.from||o(O.from,O.to,O.value))&&(h.addInner(O.from,O.to,O.value)||l.push(_i.create(O.from,O.to,O.value))),O.next());return h.finishInner(this.nextLayer.isEmpty&&!l.length?i.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filt
`)}static newName(){let e=Aa[ja]||1;return Aa[ja]=e+1,gs+e.toString(36)}static mount(e,t,n){let r=e[Qs],s=n&&n.nonce;r?s&&r.setNonce(s):r=new Ss(e,s),r.mount(Array.isArray(t)?t:[t])}},_a=new Map,Ss=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=_a.get(n);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[Qs]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],_a.set(n,this)}else{this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[Qs]=this}mount(e){let t=this.sheet,n=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],O=this.modules.indexOf(o);if(O<r&&O>-1&&(this.modules.splice(O,1),r--,O=-1),O==-1){if(this.modules.splice(r++,0,o),t)for(let a=0;a<o.rules.length;a++)t.insertRule(o.rules[a],n++)}else{for(;r<O;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var pt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},pi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ed=typeof navigator<"u"&&/Mac/.test(navigator.platform),Gd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(re=0;re<10;re++)pt[48+re]=pt[96+re]=String(re);var re;for(re=1;re<=24;re++)pt[re+111]="F"+re;var re;for(re=65;re<=90;re++)pt[re]=String.fromCharCode(re+32),pi[re]=String.fromCharCode(re);var re;for(Gn in pt)pi.hasOwnProperty(Gn)||(pi[Gn]=pt[Gn]);var Gn;function Ua(i){var e=Ed&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Gd&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?pi:pt)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function rr(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function ks(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Md(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Kn(i,e){if(!e.anchorNode)return!1;try{return ks(i,e.anchorNode)}catch{return!1}}function Ji(i){return i.nodeType==3?Nt(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Di(i,e,t,n){return t?Ea(i,e,t,n,-1)||Ea(i,e,t,n,1):!1}function en(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Ea(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:mt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=en(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?mt(i):0}else return!1}}function mt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function ao(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Id(i){return{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function bl(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function Ld(i,e,t,n,r,s,o,O){let a=i.ownerDocument,l=a.defaultView||window;for(let h=i,c=!1;h&&!c;)if(h.nodeType==1){let f,d=h==a.body,p=1,m=1;if(d)f=Id(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(c=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let Q=h.getBoundingClientRect();({scaleX:p,scaleY:m}=bl(h,Q)),f={left:Q.left,right:Q.left+h.clientWidth*p,top:Q.top,bottom:Q.top+h.clientHeight*m}}let $=0,g=0;if(r=="nearest")e.top<f.top?(g=-(f.top-e.top+o),t>0&&e.bottom>f.bottom+g&&(g=e.bottom-f.bottom+g+o)):e.bottom>f.bottom&&(g=e.bottom-f.bottom+o,t<0&&e.top-g<f.top&&(g=-(f.top+g-e.top+o)));else{let Q=e.bottom-e.top,x=f.bottom-f.top;g=(r=="center"&&Q<=x?e.top+Q/2-x/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-x+o)-f.top}if(n=="nearest"?e.left<f.left?($=-(f.left-e.left+s),t>0&&e.right>f.right+$&&($=e.right-f.right+$+s)):e.right>f.right&&($=e.right-f.right+s,t<0&&e.left<f.left+$&&($=-(f.left+$-e.left+s))):$=(n=="center"?e.left+(e.right-e.left)/2
`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),l=i.visualLineSide(r,!t)}if(a){if(!a(h))return O}else{if(!n)return l;a=n(h)}O=l}}function xp(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==Ae.Space&&(r=o),r==o}}function wp(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return S.cursor(r,e.assoc);let o=e.goalColumn,O,a=i.contentDOM.getBoundingClientRect(),l=i.coordsAtPos(r,e.assoc||-1),h=i.documentTop;if(l)o==null&&(o=l.left-a.left),O=s<0?l.top:l.bottom;else{let d=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-d.from))),O=(s<0?d.top:d.bottom)+h}let c=a.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=O+(f+d)*s,m=th(i,{x:c,y:p},!1,s);if(p<a.top||p>a.bottom||(s<0?m<r:m>r)){let $=i.docView.coordsForChar(m),g=!$||p<$.top?-1:1;return S.cursor(m,g,void 0,o)}}}function Jn(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,O)=>{if(e>s&&e<o){let a=n||t||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function bs(i,e,t){let n=Jn(i.state.facet(uo).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:S.cursor(n,n<t.from?1:-1)}var _s=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&_p(e.contentDOM.ownerDocument)}handleEvent(e){!Wp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=kp(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,O=n[s];O&&o!=!O.handlers.length&&(r.removeEventListener(s,this.handleEvent),O=null),O||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&nh.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=ih.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Tp.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Qi(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:z.safari&&!z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function tl(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){ot(t.state,r)}}}function kp(i){let e=Object.create(null);function t(n){return e[n]||(e[
`&&i.lineWrapping&&(n&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:j.of([" "])}),t){if(z.ios&&i.inputState.flushIOSKey()||z.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Qi(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Qi(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Qi(i.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let O,a=()=>O||(O=Np(i,t,n));return i.state.facet(Ml).some(l=>l(i,t.from,t.to,o,a))||i.dispatch(a()),!0}else if(n&&!n.main.eq(r)){let o=!1,O="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),O=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:O}),!0}else return!1}function Np(i,e,t){let n,r=i.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let O=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(O+e.insert.sliceString(0,void 0,i.state.lineBreak)+a))}else{let O=r.changes(e),a=t&&t.main.to<=O.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let l=i.state.sliceDoc(e.from,e.to),h,c=t&&Jl(i,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-p}}else h=i.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:O,range:a||p.map(O)};let m=p.to-f,$=m-l.length;if(p.to-p.from!=d||i.state.sliceDoc($,m)!=l||p.to>=h.from&&p.from<=h.to)return{range:p};let g=r.changes({from:$,to:m,insert:e.insert}),Q=p.to-s.to;return{changes:g,range:a?S.range(Math.max(0,a.anchor+Q),Math.max(0,a.head+Q)):p.map(g)}})}else n={changes:O,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:o,scrollIntoView:!0})}function Hp(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,O=e.length;for(;o>0&&O>0&&i.charCodeAt(o-1)==e.charCodeAt(O-1);)o--,O--;if(n=="end"){let a=Math.max(0,s-Math.min(o,O));t-=o+a-s}if(o<s&&i.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,O=s+(O-o),o=s}else if(O<s){let a=t<=s&&t>=O?s-t:0;s-=a,o=s+(o-O),O=s}return{from:s,toA:o,toB:O}}function Fp(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new ur(t,n)),(r!=t||s!=n)&&e.push(new ur(r,s))),e}function Kp(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?S.single(t+e,n+e):null}var Jp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},xs=z.ie&&z.ie_version<=11,to=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Ts,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),xs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChan
`&&(t="");else{let n=t.indexOf(`
`);n>-1&&(t=t.slice(0,n))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=n||(t=t.slice(0,s-(n-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,O=this.lineAfter(o);t+=O,n=o+O.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(n>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(n,s,-1),n+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,n,r),s}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new vr(t,e?e.state.tabSize:4,e?Vt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let O=ic(s.token,o,this.state);if(O&&(r=this.emitToken(this.lang.tokenTable.resolve(O),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=q.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:s$,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new q(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new q(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function ic(i,e,t){e.start=e.pos;for(let n=0;n<10;n++){let r=i(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var Lo=Object.create(null),un=[ie.none],s$=new $t(un),Eh=[],Gh=Object.create(null),nc=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])nc[i]=rc(Lo,e);var Zr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),nc)}resolve(e){return e?this.table[e]||(this.table[e]=rc(this.extra,e)):0}},o$=new Zr(Lo);function qo(i,e){Eh.indexOf(i)>-1||(Eh.push(i),console.warn(e))}function rc(i,e){let t=[];for(let O of e.split(" ")){let a=[];for(let l of O.split(".")){let h=i[l]||u[l];h?typeof h=="function"?a.length?a=a.map(h):qo(l,`Modifier ${l} used at start of tag`):a.length?qo(l,`Tag ${l} used as modifier`):a=Array.isArray(h)?h:[h]:qo(l,`Unknown highlighting tag ${l}`)}for(let l of a)t.push(l)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(O=>O.id),s=Gh[r];if(s)return s.id;let o=Gh[r]=ie.define({id:un.length,name:n,props:[oe({[n]:t})]});return un.push(o),o.id}function O$(i){let e=ie.define({id:un.length,name:"Document",props:[St.add(()=>i)],top:!0});return un.push(e),e}var zP={rtl:I.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:K.RTL}),ltr:I.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:K.LTR}),auto:I.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var a$=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Jo(i.state,t.from);return n.line?l$(i):n.block?c$(i):!1};function Ko(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}var l$=Ko(d$,0);var h$=Ko(fc,0);var c$=Ko((i,e)=>fc(i,e,u$(e)),0);function Jo(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var mn=50;function f$(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-mn,n),o=i.sliceDoc(r,r+mn),O=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,l=s.length-O;if(s.slice(l-e.length,l)==e&&o.slice(a,a+t.length)==t)r
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),Pe("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Pe(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),Pe(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),Pe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Pe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],UQ=Rf.concat([Pe("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Pe("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Pe("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Zf=new Pi,Vf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function bn(i){return(e,t)=>{let n=e.node.getChild("VariableDefinition");return n&&t(n,i),!0}}var EQ=["FunctionDeclaration"],GQ={FunctionDeclaration:bn("function"),ClassDeclaration:bn("class"),ClassExpression:()=>!0,EnumDeclaration:bn("constant"),TypeAliasDeclaration:bn("type"),NamespaceDeclaration:bn("namespace"),VariableDefinition(i,e){i.matchContext(EQ)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function qf(i,e){let t=Zf.get(e);if(t)return t;let n=[],r=!0;function s(o,O){let a=i.sliceString(o.from,o.to);n.push({label:a,type:O})}return e.cursor(G.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let O=GQ[o.name];if(O&&O(o,s)||Vf.has(o.name))return!1}else if(o.to-o.from>8192){for(let O of qf(i,o.node))n.push(O);return!1}}),Zf.set(e,n),n}var Xf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Yf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName",".","?."];function MQ(i){let e=M(i.state).resolveInner(i.pos,-1);if(Yf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&Xf.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let n=[];for(let r=e;r;r=r.parent)Vf.has(r.name)&&(n=n.concat(qf(i.state.doc,r)));return{options:n,from:t?e.from:i.pos,validFor:Xf}}var et=ue.define({name:"javascript",parser:bf.configure({props:[Se.add({IfStatement:Re({except:/^\s*({|else\b)/}),TryStatement:Re({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Bh,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:n?1:2)*i.unit},Block:Wr({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":Re({except:/^{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),ye.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Yt,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Cf={test:i=>/^JSX/.test(i.name),facet:ki({commentTokens:{block:{open:"{/*",close:"*/}"}}})},xO=et.configure({dialect:"ts"},"typescript"),wO=et.configure({dialect:"jsx",props:[Xr.add(i=>i.isTop?[Cf]:void 0)]}),kO=et.configure({dialect:"jsx ts",props:[Xr.add(i=>i.isTop?[Cf]:void 0)]},"typescript"),jf=i=>({label:i,type:"keyword"}),Af="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(jf),IQ=Af.concat(["declare","implements","private","protected","public"].map(jf));function ni(i={}){let e=i.jsx?i.typescript?kO:wO:i.typescript?xO:et,t=i.typescript?UQ.concat(IQ):Rf.concat(Af);return new Oe(e,[et.data.of({autocomplete:Tf(Yf,kf(t))}),et.data.of({autocomplete:MQ}),i.jsx?BQ:[]])}function LQ(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function Wf(i,e,t=i.length){for(let n=e?.firstChild;n;n=n.nextSiblin
`+t.scrub(),s=this.advance(r);return s>-1&&s<r.length?this.complete(e,n,s):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Tn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,n){return e.addLeafElement(t,_(y.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Mu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(_(y.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Eu(e,Tn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Tn(e,this.pos),n=0;if(t>this.pos){let r=Gu(e,t,this.start);if(r){let s=jO(e,r.to-this.start);s>0&&(this.nextStage(r),n=s)}}return n||(n=jO(e,this.pos)),n>0&&n<e.length?n:-1}else return jO(e,this.pos)}}};function jO(i,e){for(;e<i.length;e++){let t=i.charCodeAt(e);if(t==10)break;if(!Le(t))return-1}return e}var IO=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Vu(t),s=t.next;if(r<0)return!1;let o=_(y.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,_(s==61?y.SetextHeading1:y.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}},jS={LinkReference(i,e){return e.content.charCodeAt(0)==91?new MO(e):null},SetextHeading(){return new IO}},AS=[(i,e)=>Ru(e)>=0,(i,e)=>Zu(e)>=0,(i,e)=>Xu(e)>=0,(i,e)=>JO(e,i,!0)>=0,(i,e)=>ea(e,i,!0)>=0,(i,e)=>KO(e,i,!0)>=0,(i,e)=>Cu(e,i,!0)>=0],_S={text:"",end:0},LO=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new UO,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Hr.create(y.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new HO(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let n=0;;){let r=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<e.markers.length&&(!r||e.markers[n].from<r.end);){let s=e.markers[n++];this.addNode(s.type,s.from,s.to)}if(!r)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let r=n(this,e);if(r!=!1){if(r==!0)return null;e.forward();continue e}}break}let t=new _O(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let r=n(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break e}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
`+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=Iu(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=_S;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let n=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<t.end;){r++;let s=this.ranges[r].from,o=this.lineChunkAt(s);t.end=s+o.length,t.text=t.text.slice(0,this.ranges[r-1].to-n)+o,n=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let r=this.stack[e.depth],s=this.parser.skipContextMarkup[r.type];if(!s)throw new Error("Unhandled block context "+y[r.type]);if(!s(r,this,e))break;e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
`?"":t;else{let r=t.indexOf(`
`);n=r<0?t:t.slice(0,r)}return e+n.length>this.to?n.slice(0,this.to-e):n}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=Hr.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){typeof e=="number"&&(e=new q(this.parser.nodeSet.types[e],Ri,Ri,(n??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(NO(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?ju(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let n of e.parsers)if(n.finish(this,e))return;let t=NO(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(y.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return typeof e=="string"?_(this.parser.getNodeType(e),t,n,r):new Kr(e,t)}get buffer(){return new Fr(this.parser.nodeSet)}};function ju(i,e,t,n,r){let s=i[e].to,o=[],O=[],a=t.from+n;function l(h,c){for(;c?h>=s:h>s;){let f=i[e+1].from-s;n+=f,h+=f,e++,s=i[e].to}}for(let h=t.firstChild;h;h=h.nextSibling){l(h.from+n,!0);let c=h.from+n,f,d=r.get(h.tree);d?f=d:h.to+n>s?(f=ju(i,e,h,n,r),l(h.to+n,!1)):f=h.toTree(),o.push(f),O.push(c-a)}return l(t.to+n,!1),new q(t.type,o,O,t.to+n-a,t.tree?t.tree.propValues:void 0)}var zn=class i extends Qt{constructor(e,t,n,r,s,o,O,a,l){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=o,this.inlineParsers=O,this.inlineNames=a,this.wrappers=l,this.nodeTypes=Object.create(null);for(let h of e.types)this.nodeTypes[h.name]=h.id}createParse(e,t,n){let r=new LO(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let t=DO(e);if(!t)return this;let{nodeSet:n,skipContextMarkup:r}=this,s=this.blockParsers.slice(),o=this.leafBlockParsers.slice(),O=this.blockNames.slice(),a=this.inlineParsers.slice(),l=this.inlineNames.slice(),h=this.endLeafBlock.slice(),c=this.wrappers;if(wn(t.defineNodes)){r=Object.assign({},r);let f=n.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:$,composite:g,style:Q}=typeof p=="string"?{name:p}:p;if(f.some(P=>P.name==m))continue;g&&(r[f.length]=(P,v,k)=>g(v,k,P.value));let x=f.length,w=g?["Block","BlockContext"]:$?x>=y.ATXHeading1&&x<=y.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(ie.define({id:x,name:m,props:w&&[[R.group,w]]})),Q&&(d||(d={}),Array.isArray(Q)||Q instanceof Ge?d[m]=Q:Object.assign(d,Q))}n=new $t(f),d&&(n=n.extend(oe(d)))}if(wn(t.props)&&(n=n.extend(...t.props)),wn(t.remove))for(let f of t.remove){let d=this.blockNames.indexOf(f),p=this.inlineNames.indexOf(f);d>-1&&(s[d]=o[d]=void 0),p>-1&&(a[p]=void 0)}if(wn(t.parseBlock))for(let f of t.parseBlock){let d=O.indexOf(f.name);if(d>-1)s[d]=f.parse,o[d]=f.leaf;else{let p=f.before?Nr(O,f.before):f.after?Nr(O,f.after)+1:O.length-1;s.splice(p,0,f.parse),o.splice(p,0,f.leaf),O.splice(p,0,f.name)}f.endLeaf&&h.push(f.endLeaf)}if(wn(t.parseInline))for(let f of t.parseInline){let d=l.indexOf(f.name);if(d>-1)a[d]=f.parse;else{let p=f.before?Nr(l,f.before):f.after?Nr(l,f.after)+1:l.length-1;a.splice(p,0,f.parse),l.splice(p,0,f.name)}}return t.wrap&&(c=c.concat(t.wrap)),new i(n,s,o,O,h,r,a,l,c)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new BO(this,e,t);e:for(let r=t;r<n.end;){let s=n.char(r);for(let o of this.inlineParsers)if(o){let O=o(n,s,r);if(O>=0){r=O;continue e}}r++}return n.resol
`;)s--;this.fragmentEnd=s?s-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(R.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,O=e.block.children.length,a=o,l=O;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let h=Iu(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,h);else{let c=new q(e.parser.nodeSet.types[y.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(c,t.tree),e.addNode(c,h)}if(t.type.is("Block")&&(ES.indexOf(t.type.id)<0?(o=t.to-n,O=e.block.children.length):(o=a,O=l,a=t.to-n,l=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>O;)e.block.children.pop(),e.block.positions.pop();return o-s}};function Iu(i,e){let t=i;for(let n=1;n<e.length;n++){let r=e[n-1].to,s=e[n].from;r<i&&(t-=s-r)}return t}var GS=oe({"Blockquote/...":u.quote,HorizontalRule:u.contentSeparator,"ATXHeading1/... SetextHeading1/...":u.heading1,"ATXHeading2/... SetextHeading2/...":u.heading2,"ATXHeading3/...":u.heading3,"ATXHeading4/...":u.heading4,"ATXHeading5/...":u.heading5,"ATXHeading6/...":u.heading6,"Comment CommentBlock":u.comment,Escape:u.escape,Entity:u.character,"Emphasis/...":u.emphasis,"StrongEmphasis/...":u.strong,"Link/... Image/...":u.link,"OrderedList/... BulletList/...":u.list,"BlockQuote/...":u.quote,"InlineCode CodeText":u.monospace,"URL Autolink":u.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":u.processingInstruction,"CodeInfo LinkLabel":u.labelName,LinkTitle:u.string,Paragraph:u.content}),Lu=new zn(new $t(Au).extend(GS),Object.keys(Br).map(i=>Br[i]),Object.keys(Br).map(i=>jS[i]),Object.keys(Br),AS,zu,Object.keys(AO).map(i=>AO[i]),Object.keys(AO),[]);function MS(i,e,t){let n=[];for(let r=i.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:t;if(o>s&&n.push({from:s,to:o}),!r)break;s=r.to}return n}function Du(i){let{codeParser:e,htmlParser:t}=i;return{wrap:bi((r,s)=>{let o=r.type.id;if(e&&(o==y.CodeBlock||o==y.FencedCode)){let O="";if(o==y.FencedCode){let l=r.node.getChild(y.CodeInfo);l&&(O=s.read(l.from,l.to))}let a=e(O);if(a)return{parser:a,overlay:l=>l.type.id==y.CodeText}}else if(t&&(o==y.HTMLBlock||o==y.HTMLTag))return{parser:t,overlay:MS(r.node,r.from,r.to)};return null})}}var IS={resolve:"Strikethrough",mark:"StrikethroughMark"},LS={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":u.strikethrough}},{name:"StrikethroughMark",style:u.processingInstruction}],parseInline:[{name:"Strikethrough",parse(i,e,t){if(e!=126||i.char(t+1)!=126||i.char(t+2)==126)return-1;let n=i.slice(t-1,t),r=i.slice(t+2,t+3),s=/\s|^$/.test(n),o=/\s|^$/.test(r),O=Zn.test(n),a=Zn.test(r);return i.addDelimiter(IS,t,t+2,!o&&(!a||s||O),!s&&(!O||o||a))},after:"Emphasis"}]};function vn(i,e,t=0,n,r=0){let s=0,o=!0,O=-1,a=-1,l=!1,h=()=>{n.push(i.elt("TableCell",r+O,r+a,i.parser.parseInline(e.slice(O,a),r+O)))};for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);f==124&&!l?((!o||O>-1)&&s++,o=!1,n&&(O>-1&&h(),n.push(i.elt("TableDelimiter",c+r,c+r+1))),O=a=-1):(l||f!=32&&f!=9)&&(O<0&&(O=c),a=c+1),l=!l&&f==92}return O>-1&&(s++,n&&h()),s}function Pu(i,e){for(let t=e;t<i.length;t++){let n=i.charCodeAt(t);if(n==124)return!0;n==92&&t++}return!1}var Bu=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,Jr=class{constructor(){this.rows=null}nextLine(e,t,n){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&Bu.test(r=t.text.slice(t.pos))){let s=[];vn(e,n.content,0,s,n.start)==vn(e,r,t.pos)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,s),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let r=[];vn(e,t.text,t.pos,r,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,r))}return!1}finish(e,t){return this.rows?(e.addLea
`);let t=i.textContent.trimEnd(),n="",r="";e!==null&&(n=e.className.replace("language-",""),r=e.getAttribute("dir"));let s=document.createElement("div");i.parentNode.insertBefore(s,i);let o=r||i.getAttribute("dir")||"";o&&s.setAttribute("dir",o);let O=qi("content-code-block",{parent:s,doc:t,extensions:rO(s)});new Et(O).setMode(n,t),i.remove(),tP(O)}function Eb(i){let e=i.querySelectorAll("pre");for(let t of e)vd(t)}function Gb(){let i=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of i)vd(e)}function Mb(i,e,t,n){let r=qi("content-code-block",{parent:i,doc:t,extensions:rO(i),root:e}),s=new Et(r);return s.setMode(n,t),s}function Ib(i,e){let t=i.textContent,n={parent:i.parentElement,doc:t,extensions:[..._r(i.parentElement)]},r=new Et(qi("code-editor",n));return r.setMode(e,t),i.style.display="none",r}function Lb(i,e){let t=i.value,n={parent:i.parentElement,doc:t,extensions:[..._r(i.parentElement),T.updateListener.of(o=>{o.docChanged&&(i.value=o.state.doc.toString())})]},r=qi("code-input",n),s=new Et(r);return s.setMode(e,t),i.style.display="none",s}function Db(i,e,t,n){let r=i.textContent,s={parent:i.parentElement,doc:r,extensions:[at.of(n),..._r(i.parentElement),T.updateListener.of(O=>{e(O)}),T.domEventHandlers(t)]};window.$events.emitPublic(i,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let o=qi("markdown-editor",s);return new Et(o).setMode("markdown",""),i.style.display="none",o}export{Gb as highlight,Eb as highlightWithin,Lb as inlineEditor,Db as markdownEditor,Ib as popupEditor,Mb as wysiwygView};
//# sourceMappingURL=code.js.map