BookStack/public/dist/code.js

31 lines
591 KiB
JavaScript
Raw Normal View History

var U=class{constructor(){}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,i){let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),je.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),je.from(i,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),i=this.length-this.scanIdentical(e,-1),r=new Ft(this),s=new Ft(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>=i)return!0}}iter(e=1){return new Ft(this,e)}iterRange(e,t=this.length){return new jn(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Gn(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?U.empty:e.length<=32?new F(e):je.from(F.split(e,[]))}},F=class extends U{constructor(e,t=nd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let O=this.text[s],o=r+O.length;if((t?i:o)>=e)return new Os(r,o,i,O);r=o+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new F(tl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let O=i.pop(),o=An(s.text,O.text.slice(),0,s.length);if(o.length<=32)i.push(new F(o,O.length+s.length));else{let l=o.length>>1;i.push(new F(o.slice(0,l)),new F(o.slice(l)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof F))return super.replace(e,t,i);let r=An(this.text,An(i.text,tl(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new F(r,s):je.from(F.split(r,[]),s)}sliceString(e,t=this.length,i=`
`){let r="";for(let s=0,O=0;s<=t&&O<this.text.length;O++){let o=this.text[O],l=s+o.length;s>e&&O&&(r+=i),e<l&&t>s&&(r+=o.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new F(i,r)),i=[],r=-1);return r>-1&&t.push(new F(i,r)),t}},je=class extends U{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let O=this.children[s],o=r+O.length,l=i+O.lines-1;if((t?l:o)>=e)return O.lineInner(e,t,i,r);r=o+1,i=l+1}}decompose(e,t,i,r){for(let s=0,O=0;O<=t&&s<this.children.length;s++){let o=this.children[s],l=O+o.length;if(e<=l&&t>=O){let a=r&((O<=e?1:0)|(l>=t?2:0));O>=e&&l<=t&&!a?i.push(o):o.decompose(e-O,t-O,i,a)}O=l+1}}replace(e,t,i){if(i.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 l=O.replace(e-s,t-s,i),a=this.lines-O.lines+l.lines;if(l.lines<a>>5-1&&l.lines>a>>5+1){let h=this.children.slice();return h[r]=l,new je(h,this.length-(t-e)+i.length)}return super.replace(s,o,l)}s=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
`){let r="";for(let s=0,O=0;s<this.children.length&&O<=t;s++){let o=this.children[s],l=O+o.length;O>e&&s&&(r+=i),e<l&&t>O&&(r+=o.sliceString(e-O,t-O,i)),O=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof je))return 0;let i=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 i;let l=this.children[r],a=e.children[s];if(l!=a)return i+l.scanIdentical(a,t);i+=l.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new F(d,t)}let r=Math.max(32,i>>5),s=r<<1,O=r>>1,o=[],l=0,a=-1,h=[];function c(d){let p;if(d.lines>s&&d instanceof je)for(let m of d.children)c(m);else d.lines>O&&(l>O||!l)?(f(),o.push(d)):d instanceof F&&l&&(p=h[h.length-1])instanceof F&&d.lines+p.lines<=32?(l+=d.lines,a+=d.length+1,h[h.length-1]=new F(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>r&&f(),l+=d.lines,a+=d.length+1,h.push(d))}function f(){l!=0&&(o.push(h.length==1?h[0]:je.from(h,a)),a=-1,l=h.length=0)}for(let d of e)c(d);return f(),o.length==1?o[0]:new je(o,t)}};U.empty=new F([""],0);function nd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function An(n,e,t=0,i=1e9){for(let r=0,s=0,O=!0;s<n.length&&r<=i;s++){let o=n[s],l=r+o.length;l>=t&&(l>i&&(o=o.slice(0,i-r)),r<t&&(o=o.slice(t-r)),O?(e[e.length-1]+=o,O=!1):e.push(o)),r=l+1}return e}function tl(n,e,t){return An(n,[""],e,t)}var Ft=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 F?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],O=s>>1,o=r instanceof F?r.text.length:r.children.length;if(O==(t>0?o:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof F){let l=r.text[O+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[O+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof F?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},jn=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ft(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),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!=""}},Gn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(U.prototype[Symbol.iterator]=function(){return this.iter()},Ft.prototype[Symbol.iterator]=jn.prototype[Symbol.iterator]=Gn.prototype[Symbol.iterator]=function(){return this});var Os=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}},ui="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(n=>n?parseInt(n,36):1);for(let n=1;n<ui.length;n++)ui[n]+=ui[n-1];function rd(n){for(let e=1;e<ui.length;e+=2)if(ui[e]>n)return ui[e-1]<=n;return!1}function il(n){return n>=127462&&n<=127487}var nl=8205;function we(n,e,t=!0,i=!0){return(t?al:sd)(n,e,i)}function al(n,e,t){if(e==n.length)return e;e&&hl(n.charCodeAt(e))&&cl(n.charCodeAt(e-1))&&e--;let i=di(n,e);for(e+=Ji(i);e<n.length;){let r=di(n,e);if(i==nl||r==nl||t&&rd(r))e+=Ji(r),i=r;else if(il(r)){let s=0,O=e-2;for(;O>=0&&il(di(n,O));)s++,O-=2;if(s%2==0)break;e+=2}else break}return e}function sd(n,e,t){for(;e>0;){let i=al(n,e-2,t);if(i<e)return i;e--}return 0}function hl(n){return n>=56320&&n<57344}function cl(n){return n>=55296&&n<56320}function di(n,e){let t=n.charCodeAt(e);if(!cl(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return hl(i)?(t-55296<<10)+(i-56320)+65536:t}function Ji(n){return n<65536?1:2}var os=/\r\n?|\n/,pe=function(n){ret
`}get readOnly(){return this.facet(Sl)}phrase(e,...t){for(let i of this.facet(Y.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(dl))for(let O of s(this,t,i))Object.prototype.hasOwnProperty.call(O,e)&&r.push(O[e]);return r}charCategorizer(e){return dd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),O=e-i,o=e-i;for(;O>0;){let l=we(t,O,!1);if(s(t.slice(l,O))!=Ge.Word)break;O=l}for(;o<r;){let l=we(t,o);if(s(t.slice(o,l))!=Ge.Word)break;o=l}return O==o?null:Q.range(O+i,o+i)}};Y.allowMultipleSelections=pl;Y.tabSize=W.define({combine:n=>n.length?n[0]:4});Y.lineSeparator=$l;Y.readOnly=Sl;Y.phrases=W.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});Y.languageData=dl;Y.changeFilter=ml;Y.transactionFilter=gl;Y.transactionExtender=Ql;lt.reconfigure=G.define();function Vt(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let O=r[s],o=i[s];if(o===void 0)i[s]=O;else if(!(o===O||O===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](o,O);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ke=class{eq(e){return this==e}range(e,t=e){return Kt.create(e,t,this)}};Ke.prototype.startSide=Ke.prototype.endSide=0;Ke.prototype.point=!1;Ke.prototype.mapMode=pe.TrackDel;var Kt=class{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Kt(e,t,i)}};function ps(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var en=class{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let O=r,o=s.length;;){if(O==o)return O;let l=O+o>>1,a=s[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==O)return a>=0?O:o;a>=0?o=l:O=l+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),O=this.findIndex(i,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 i=[],r=[],s=[],O=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,f,d;if(h==c){let p=t.mapPos(h,a.startSide,a.mapMode);if(p==null||(f=d=p,a.startSide!=a.endSide&&(d=t.mapPos(h,a.endSide),d<f)))continue}else if(f=t.mapPos(h,a.startSide),d=t.mapPos(c,a.endSide),f>d||f==d&&a.startSide>0&&a.endSide<=0)continue;(d-f||a.endSide-a.startSide)<0||(O<0&&(O=f),a.point&&(o=Math.max(o,d-f)),i.push(a),r.push(f-O),s.push(d-O))}return{mapped:i.length?new en(r,s,i,o):null,pos:O}}},j=class{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new j(e,t,i,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:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,O=e.filter;if(t.length==0&&!O)return this;if(i&&(t=t.slice().sort(ps)),this.isEmpty)return t.length?j.of(t):this;let o=new Mn(this,null,-1).goto(0),l=0,a=[],h=new Pt;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let c=t[l++];h.addInner(c.from,c.to,c.value)||a.push(c)}else o.rangeIndex==1&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].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)||a.push(Kt.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?j.empty:this.nextLayer.update({add:a,filter:O,filterFrom:r,filterTo
`)}static newName(){let e=xl[bl]||1;return xl[bl]=e+1,Qs+e.toString(36)}static mount(e,t){(e[Ss]||new ys(e)).mount(Array.isArray(t)?t:[t])}},wl=new Map,ys=class{constructor(e){let t=e.ownerDocument||e,i=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let r=wl.get(t);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[Ss]=r;this.sheet=new i.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],wl.set(t,this)}else{this.styleTag=t.createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[Ss]=this}mount(e){let t=this.sheet,i=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 l=0;l<O.rules.length;l++)t.insertRule(O.rules[l],i++)}else{for(;r<o;)i+=this.modules[r++].rules.length;i+=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}}};var bt={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:"'"},gi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kl=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),rP=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),$d=typeof navigator<"u"&&/Mac/.test(navigator.platform),md=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),gd=$d||kl&&+kl[1]<57;for(re=0;re<10;re++)bt[48+re]=bt[96+re]=String(re);var re;for(re=1;re<=24;re++)bt[re+111]="F"+re;var re;for(re=65;re<=90;re++)bt[re]=String.fromCharCode(re+32),gi[re]=String.fromCharCode(re);var re;for(Bn in bt)gi.hasOwnProperty(Bn)||(gi[Bn]=bt[Bn]);var Bn;function vl(n){var e=gd&&(n.ctrlKey||n.altKey||n.metaKey)||md&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?gi:bt)[n.keyCode]||n.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 Or(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function bi(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Qd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function tr(n,e){if(!e.anchorNode)return!1;try{return bi(n,e.anchorNode)}catch{return!1}}function an(n){return n.nodeType==3?xi(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function or(n,e,t,i){return t?Tl(n,e,t,i,-1)||Tl(n,e,t,i,1):!1}function lr(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Tl(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:hn(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=lr(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?hn(n):0}else return!1}}function hn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}var la={left:0,right:0,top:0,bottom:0};function oO(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Sd(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function yd(n,e,t,i,r,s,O,o){let l=n.ownerDocument,a=l.defaultView||window;for(let h=n;h;)if(h.nodeType==1){let c,f=h==l.body;if(f)c=Sd(a);else{if(h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let m=h.getBoundingClientRect();c={left:m.left,right:m.left+h.clientWidth,top:m.top,bottom:m.top+h.clientHeight}}let d=0,p=0;if(r=="nearest")e.top<c.top?(p=-(c.top-e.top+O),t>0&&e.bottom>c.bottom+p&&(p=e.bottom-c.bottom+p+O)):e.bottom>c.bottom&&(p=e.bottom-c.bottom+O,t<0&&e.top-p<c.top&&(p=-(c.top+p-e.top+O)));else{let m=e.bottom-e.top,$=c.bottom-c.top;p=(r=="center"&&m<=$?e.top+m/2-$/2:r=="start"||r=="center"&&t<0?e.top-O:e.bottom-$+O)-c.top}if(i=="nearest"?e.left<c.left?(d=-(c.left-e.left+s),t>0&&e.right>c.right+d&&(d=e.right-c.right+d+s)):e.right>c.right&&(d=e.right-c.right+s,t<0&&e.left<c.left+d&&(d=-(c.left+d-e.left+s))):d=(i=="center"?e.left+(e.right-e.left)/2-(c.right-c.left)/2:i=="start"==o?e.left-s:e.right-(c.right-c.left)+s)-c.left,d||p)if(f)a.scrollBy(d,p);else{let m=0,$=0;if(p){let g=h.scrollTop;h.scrollTop+=p,$=h.scrollTop-g}if(d){let g=h.scrollLeft;h.scrollLeft+=d,m=h.scrollLeft-g}e={left:e.left-m,top:e.top-$,right:e.right-m,bottom:
`,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),a=Q.cursor(t?r.from:r.to)}if(l){if(!l(h))return o}else{if(!i)return a;l=i(h)}o=a}}function Ld(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let O=i(s);return r==Ge.Space&&(r=O),r==O}}function Nd(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return Q.cursor(r,e.assoc);let O=e.goalColumn,o,l=n.contentDOM.getBoundingClientRect(),a=n.coordsAtPos(r),h=n.documentTop;if(a)O==null&&(O=a.left-l.left),o=s<0?a.top:a.bottom;else{let d=n.viewState.lineBlockAt(r);O==null&&(O=Math.min(l.right-l.left,n.defaultCharacterWidth*(r-d.from))),o=(s<0?d.top:d.bottom)+h}let c=l.left+O,f=i??n.defaultLineHeight>>1;for(let d=0;;d+=10){let p=o+(f+d)*s,m=qa(n,{x:c,y:p},!1,s);if(p<l.top||p>l.bottom||(s<0?m<r:m>r))return Q.cursor(m,e.assoc,void 0,O)}}function xs(n,e,t){let i=n.state.facet(za).map(r=>r(n));for(;;){let r=!1;for(let s of i)s.between(t.from-1,t.from+1,(O,o,l)=>{t.from>O&&t.from<o&&(t=e.head>t.from?Q.cursor(O,1):Q.cursor(o,-1),r=!0)});if(!r)return t}}var Gs=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let t=(i,r)=>{this.ignoreDuringComposition(r)||r.type=="keydown"&&this.keydown(e,r)||(this.mustFlushObserver(r)&&e.observer.forceFlush(),this.runCustomHandlers(r.type,e,r)?r.preventDefault():i(e,r))};for(let i in le){let r=le[i];e.contentDOM.addEventListener(i,s=>{jl(e,s)&&t(r,s)},Is[i]),this.registeredEvents.push(i)}e.scrollDOM.addEventListener("mousedown",i=>{if(i.target==e.scrollDOM&&i.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(le.mousedown,i),!i.defaultPrevented&&i.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),z.chrome&&z.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let r;this.customHandlers=[];for(let s of t)if(r=(i=s.update(e).spec)===null||i===void 0?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:r});for(let O in r)this.registeredEvents.indexOf(O)<0&&O!="scroll"&&(this.registeredEvents.push(O),e.contentDOM.addEventListener(O,o=>{jl(e,o)&&this.runCustomHandlers(O,e,o)&&o.preventDefault()}))}}runCustomHandlers(e,t,i){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,i,t)||i.defaultPrevented)return!0}catch(O){ft(t.state,O)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let i of this.customHandlers){let r=i.handlers.scroll;if(r)try{r.call(i.plugin,t,e)}catch(s){ft(e.state,s)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(z.android&&z.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let i;return z.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((i=Ua.find(r=>r.keyCode==t.keyCode))&&!t.ctrlKey||Hd.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=i||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Pi(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.
`&&n.lineWrapping&&(i&&(i=Q.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:U.of([" "])}),t){let s=n.state;if(z.ios&&n.inputState.flushIOSKey(n)||z.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Pi(n.contentDOM,"Enter",13)||t.from==r.from-1&&t.to==r.to&&t.insert.length==0&&Pi(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Pi(n.contentDOM,"Delete",46)))return!0;let O=t.insert.toString();if(n.state.facet(xa).some(a=>a(n,t.from,t.to,O)))return!0;n.inputState.composing>=0&&n.inputState.composing++;let o;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let a=r.from<t.from?s.sliceDoc(r.from,t.from):"",h=r.to>t.to?s.sliceDoc(t.to,r.to):"";o=s.replaceSelection(n.state.toText(a+t.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=s.changes(t),h=i&&i.main.to<=a.newLength?i.main:void 0;if(s.selection.ranges.length>1&&n.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let c=n.state.sliceDoc(t.from,t.to),f=Za(n)||n.state.doc.lineAt(r.head),d=r.to-t.to,p=r.to-r.from;o=s.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:a,range:h||m.map(a)};let $=m.to-d,g=$-c.length;if(m.to-m.from!=p||n.state.sliceDoc(g,$)!=c||f&&m.to>=f.from&&m.from<=f.to)return{range:m};let P=s.changes({from:g,to:$,insert:t.insert}),k=m.to-r.to;return{changes:P,range:h?Q.range(Math.max(0,h.anchor+k),Math.max(0,h.head+k)):m.map(P)}})}else o={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),n.dispatch(o,{scrollIntoView:!0,userEvent:l}),!0}else if(i&&!i.main.eq(r)){let s=!1,O="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(s=!0),O=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:s,userEvent:O}),!0}else return!1}function dp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let O=n.length,o=e.length;for(;O>0&&o>0&&n.charCodeAt(O-1)==e.charCodeAt(o-1);)O--,o--;if(i=="end"){let l=Math.max(0,s-Math.min(O,o));t-=O+l-s}if(O<s&&n.length<e.length){let l=t<=s&&t>=O?s-t:0;s-=l,o=s+(o-O),O=s}else if(o<s){let l=t<=s&&t>=o?s-t:0;s-=l,O=s+(O-o),o=s}return{from:s,toA:O,toB:o}}function pp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new ur(t,i)),(r!=t||s!=i)&&e.push(new ur(r,s))),e}function $p(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?Q.single(t+e,i+e):null}var mp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ws=z.ie&&z.ie_version<=11,iO=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new vs,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.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),ws&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this
`&&(t="");else{let i=t.indexOf(`
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let O=this.ranges[r].from,o=this.lineAfter(O);t+=o,i=O+o.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>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,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let O=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-O}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,O=new Wr(t,e?e.state.tabSize:4,e?At(e.state):2);if(O.eol())s.blankLine(this.state,O.indentUnit);else for(;!O.eol();){let o=qh(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=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=Z.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:P$,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new Z(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 Z(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function qh(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var _O=Object.create(null),Qn=[H.none],P$=new it(Qn),bh=[],Uh=Object.create(null);for(let[n,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"]])Uh[n]=Yh(_O,e);var Rr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Uh)}resolve(e){return e?this.table[e]||(this.table[e]=Yh(this.extra,e)):0}},b$=new Rr(_O);function zO(n,e){bh.indexOf(n)>-1||(bh.push(n),console.warn(e))}function Yh(n,e){let t=null;for(let s of e.split(".")){let O=n[s]||u[s];O?typeof O=="function"?t?t=O(t):zO(s,`Modifier ${s} used at start of tag`):t?zO(s,`Tag ${s} used as modifier`):t=O:zO(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let i=e.replace(/ /g,"_"),r=H.define({id:Qn.length,name:i,props:[ae({[i]:t})]});return Qn.push(r),r.id}function x$(n){let e=H.define({id:Qn.length,name:"Document",props:[Xt.add(()=>n)]});return Qn.push(e),e}var w$=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=DO(n.state,t.from);return i.line?k$(n):i.block?T$(n):!1};function MO(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var k$=MO(W$,0);var v$=MO(Dh,0);var T$=MO((n,e)=>Dh(n,e,X$(e)),0);function DO(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Pn=50;function z$(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Pn,i),O=n.sliceDoc(r,r+Pn),o=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(O)[0].length,a=s.length-o;if(s.slice(a-e.length,a)==e&&O.slice(l,l+t.length)==t)return{open:{pos:i-o,margin:o&&1},close:{pos:r+l,margin:l&&1}};let h,c;r-i<=2*Pn?h=c=n.sliceDoc(i,r):(h=n.sliceDoc(i,i+Pn),c=n.sliceDoc(r-Pn,r));let f=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-t.length;return h.slice(f,f+e.length)==e&&c.slice(p,p+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(h.charAt(f+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function X$(n){let e=[];for(let t of n
\${}
} catch (\${error}) {
\${}
}`,{label:"try",detail:"/ catch block",type:"keyword"}),Fe("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Fe(`if (\${}) {
\${}
} else {
\${}
}`,{label:"if",detail:"/ else block",type:"keyword"}),Fe(`class \${name} {
constructor(\${params}) {
\${}
}
}`,{label:"class",detail:"definition",type:"keyword"}),Fe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Fe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],$f=new Xi,Qf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function zn(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}var Lg=["FunctionDeclaration"],Ng={FunctionDeclaration:zn("function"),ClassDeclaration:zn("class"),ClassExpression:()=>!0,EnumDeclaration:zn("constant"),TypeAliasDeclaration:zn("type"),NamespaceDeclaration:zn("namespace"),VariableDefinition(n,e){n.matchContext(Lg)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function Sf(n,e){let t=$f.get(e);if(t)return t;let i=[],r=!0;function s(O,o){let l=n.sliceString(O.from,O.to);i.push({label:l,type:o})}return e.cursor(E.IncludeAnonymous).iterate(O=>{if(r)r=!1;else if(O.name){let o=Ng[O.name];if(o&&o(O,s)||Qf.has(O.name))return!1}else if(O.to-O.from>8192){for(let o of Sf(n,O.node))i.push(o);return!1}}),$f.set(e,i),i}var mf=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,yf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName"];function Hg(n){let e=I(n.state).resolveInner(n.pos,-1);if(yf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&mf.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let r=e;r;r=r.parent)Qf.has(r.name)&&(i=i.concat(Sf(n.state.doc,r)));return{options:i,from:t?e.from:n.pos,validFor:mf}}var St=he.define({name:"javascript",parser:af.configure({props:[ve.add({IfStatement:Ye({except:/^\s*({|else\b)/}),TryStatement:Ye({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Th,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:Zr({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ye({except:/^{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Ce.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":jt,BlockComment(n){return{from:n.from+2,to:n.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Pf={test:n=>/^JSX/.test(n.name),facet:qi({commentTokens:{block:{open:"{/*",close:"*/}"}}})},ho=St.configure({dialect:"ts"},"typescript"),co=St.configure({dialect:"jsx",props:[Vr.add(n=>n.isTop?[Pf]:void 0)]}),fo=St.configure({dialect:"jsx ts",props:[Vr.add(n=>n.isTop?[Pf]:void 0)]},"typescript"),Fg="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(n=>({label:n,type:"keyword"}));function li(n={}){let e=n.jsx?n.typescript?fo:co:n.typescript?ho:St;return new ce(e,[St.data.of({autocomplete:uf(yf,ff(Bg.concat(Fg)))}),St.data.of({autocomplete:Hg}),n.jsx?eQ:[]])}function Jg(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function gf(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}var Kg=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),eQ=x.inputHandler.of((n,e,t,i)=>{if((Kg?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!St.isActiveAt(n.state,e,-1))return
`+t.scrub(),s=this.advance(r);return s>-1&&s<r.length?this.complete(e,i,s):!1}finish(e,t){return(this.stage==2||this.stage==3)&&Vn(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,i){return e.addLeafElement(t,A(S.LinkReference,this.start,this.start+i,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(Qu(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(A(S.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(mu(e,Vn(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=Vn(e,this.pos),i=0;if(t>this.pos){let r=gu(e,t,this.start);if(r){let s=wo(e,r.to-this.start);s>0&&(this.nextStage(r),i=s)}}return i||(i=wo(e,this.pos)),i>0&&i<e.length?i:-1}else return wo(e,this.pos)}}};function wo(n,e){for(;e<n.length;e++){let t=n.charCodeAt(e);if(t==10)break;if(!Je(t))return-1}return e}var Ro=class{nextLine(e,t,i){let r=t.depth<e.stack.length?-1:au(t),s=t.next;if(r<0)return!1;let O=A(S.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(i,A(s==61?S.SetextHeading1:S.SetextHeading2,i.start,e.prevLineEnd(),[...e.parser.parseInline(i.content,i.start),O])),!0}finish(){return!1}},IQ={LinkReference(n,e){return e.content.charCodeAt(0)==91?new Wo(e):null},SetextHeading(){return new Ro}},MQ=[(n,e)=>lu(e)>=0,(n,e)=>su(e)>=0,(n,e)=>Ou(e)>=0,(n,e)=>Ao(e,n,!0)>=0,(n,e)=>jo(e,n,!0)>=0,(n,e)=>_o(e,n,!0)>=0,(n,e)=>fu(e,n,!0)>=0],DQ={text:"",end:0},Vo=class{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.line=new To,this.atEnd=!1,this.dontInject=new Set,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Di.create(S.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=i.length?new Uo(i,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(;e.depth<this.stack.length;)this.finishContext();for(let i of e.markers)this.addNode(i.type,i.from,i.to);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 i of this.parser.blockParsers)if(i){let r=i(this,e);if(r!=!1){if(r==!0)return null;e.forward();continue e}}break}let t=new vo(this.lineStart+e.pos,e.text.slice(e.pos));for(let i of this.parser.leafBlockParsers)if(i){let r=i(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let i of this.parser.endLeafBlock)if(i(this,e,t))break e}for(let i of t.parsers)if(i.nextLine(this,e,t))return null;t.content+=`
`+e.scrub();for(let i of e.markers)t.marks.push(i)}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);if(!t)return!1;let i=t,r=this.absoluteLineStart+t;for(let s=1;s<this.ranges.length;s++){let O=this.ranges[s-1].to,o=this.ranges[s].from;O>=this.lineStart&&o<r&&(i-=o-O)}return this.lineStart+=i,this.absoluteLineStart+=t,this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0}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=DQ;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 i=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-i)+O,i=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:i}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=i,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 "+S[r.type]);if(!s(r,this,e))break;e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),i;if(this.input.lineChunks)i=t==`
`?"":t;else{let r=t.indexOf(`
`);i=r<0?t:t.slice(0,r)}return e+i.length>this.to?i.slice(0,this.to-e):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,i=0){this.block=Di.create(e,i,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,i=0){this.startContext(this.parser.getNodeType(e),t,i)}addNode(e,t,i){typeof e=="number"&&(e=new Z(this.parser.nodeSet.types[e],Bi,Bi,(i??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(qo(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?uu(this.ranges,0,e.topNode,this.ranges[0].from,this.dontInject):e}finishLeaf(e){for(let i of e.parsers)if(i.finish(this,e))return;let t=qo(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(S.Paragraph,e.content.length),e.start)}elt(e,t,i,r){return typeof e=="string"?A(this.parser.getNodeType(e),t,i,r):new ts(e,t)}get buffer(){return new es(this.parser.nodeSet)}};function uu(n,e,t,i,r){if(r.has(t.tree))return t.tree;let s=n[e].to,O=[],o=[],l=t.from+i;function a(h,c){for(;c?h>=s:h>s;){let f=n[e+1].from-s;i+=f,h+=f,e++,s=n[e].to}}for(let h=t.firstChild;h;h=h.nextSibling){a(h.from+i,!0);let c=h.from+i,f;h.to+i>s?(f=uu(n,e,h,i,r),a(h.to+i,!1)):f=h.toTree(),O.push(f),o.push(c-l)}return a(t.to+i,!1),new Z(t.type,O,o,t.to+i-l,t.tree?t.tree.propValues:void 0)}var hi=class extends zt{constructor(e,t,i,r,s,O,o,l,a){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=O,this.inlineParsers=o,this.inlineNames=l,this.wrappers=a,this.nodeTypes=Object.create(null);for(let h of e.types)this.nodeTypes[h.name]=h.id}createParse(e,t,i){let r=new Vo(this,e,t,i);for(let s of this.wrappers)r=s(r,e,t,i);return r}configure(e){let t=Zo(e);if(!t)return this;let{nodeSet:i,skipContextMarkup:r}=this,s=this.blockParsers.slice(),O=this.leafBlockParsers.slice(),o=this.blockNames.slice(),l=this.inlineParsers.slice(),a=this.inlineNames.slice(),h=this.endLeafBlock.slice(),c=this.wrappers;if(Wn(t.defineNodes)){r=Object.assign({},r);let f=i.types.slice(),d;for(let p of t.defineNodes){let{name:m,block:$,composite:g,style:P}=typeof p=="string"?{name:p}:p;if(f.some(v=>v.name==m))continue;g&&(r[f.length]=(v,w,V)=>g(w,V,v.value));let k=f.length,b=g?["Block","BlockContext"]:$?k>=S.ATXHeading1&&k<=S.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(H.define({id:k,name:m,props:b&&[[R.group,b]]})),P&&(d||(d={}),Array.isArray(P)||P instanceof Ze?d[m]=P:Object.assign(d,P))}i=new it(f),d&&(i=i.extend(ae(d)))}if(Wn(t.props)&&(i=i.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&&(l[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?Kr(o,f.before):f.after?Kr(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=a.indexOf(f.name);if(d>-1)l[d]=f.parse;else{let p=f.before?Kr(a,f.before):f.after?Kr(a,f.after)+1:a.length-1;l.splice(p,0,f.parse),a.splice(p,0,f.name)}}return t.wrap&&(c=c.concat(t.wrap)),new hi(i,s,O,o,h,r,l,a,c)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let i=new Co(this,e,t);e:for(let r=t;r<i.end;){let s=i.char(r);for(let O of this.inlineParsers)if(O){let o=O(i,s,r);if(o>=0){r=o;continue e}}r++}return i.resol
`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=t;if(!i.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(R.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,O=s,o=e.block.children.length,l=O,a=o;for(;;){if(t.to-i>r){if(t.type.isAnonymous&&t.firstChild())continue;break}if(e.dontInject.add(t.tree),e.addNode(t.tree,t.from-i),t.type.is("Block")&&(LQ.indexOf(t.type.id)<0?(O=t.to-i,o=e.block.children.length):(O=l,o=a,l=t.to-i,a=e.block.children.length)),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return O-s}},NQ=ae({"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:u.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":u.processingInstruction,"CodeInfo LinkLabel":u.labelName,LinkTitle:u.string,Paragraph:u.content}),Su=new hi(new it(du).extend(NQ),Object.keys(Jr).map(n=>Jr[n]),Object.keys(Jr).map(n=>IQ[n]),Object.keys(Jr),MQ,ru,Object.keys(ko).map(n=>ko[n]),Object.keys(ko),[]);function HQ(n,e,t){let i=[];for(let r=n.firstChild,s=e;;r=r.nextSibling){let O=r?r.from:t;if(O>s&&i.push({from:s,to:O}),!r)break;s=r.to}return i}function yu(n){let{codeParser:e,htmlParser:t}=n;return{wrap:Wi((r,s)=>{let O=r.type.id;if(e&&(O==S.CodeBlock||O==S.FencedCode)){let o="";if(O==S.FencedCode){let a=r.node.getChild(S.CodeInfo);a&&(o=s.read(a.from,a.to))}let l=e(o);if(l)return{parser:l,overlay:a=>a.type.id==S.CodeText}}else if(t&&(O==S.HTMLBlock||O==S.HTMLTag))return{parser:t,overlay:HQ(r.node,r.from,r.to)};return null})}}var FQ={resolve:"Strikethrough",mark:"StrikethroughMark"},JQ={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":u.strikethrough}},{name:"StrikethroughMark",style:u.processingInstruction}],parseInline:[{name:"Strikethrough",parse(n,e,t){if(e!=126||n.char(t+1)!=126||n.char(t+2)==126)return-1;let i=n.slice(t-1,t),r=n.slice(t+2,t+3),s=/\s|^$/.test(i),O=/\s|^$/.test(r),o=Cn.test(i),l=Cn.test(r);return n.addDelimiter(FQ,t,t+2,!O&&(!l||s||o),!s&&(!o||O||l))},after:"Emphasis"}]};function Zn(n,e,t=0,i,r=0){let s=0,O=!0,o=-1,l=-1,a=!1,h=()=>{i.push(n.elt("TableCell",r+o,r+l,n.parser.parseInline(e.slice(o,l),r+o)))};for(let c=t;c<e.length;c++){let f=e.charCodeAt(c);f==124&&!a?((!O||o>-1)&&s++,O=!1,i&&(o>-1&&h(),i.push(n.elt("TableDelimiter",c+r,c+r+1))),o=l=-1):(a||f!=32&&f!=9)&&(o<0&&(o=c),l=c+1),a=!a&&f==92}return o>-1&&(s++,i&&h()),s}function nu(n,e){for(let t=e;t<n.length;t++){let i=n.charCodeAt(t);if(i==124)return!0;i==92&&t++}return!1}var Pu=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/,is=class{constructor(){this.rows=null}nextLine(e,t,i){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&Pu.test(r=t.text.slice(t.pos))){let s=[];Zn(e,i.content,0,s,i.start)==Zn(e,r,t.pos)&&(this.rows=[e.elt("TableHeader",i.start,i.start+i.content.length,s),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let r=[];Zn(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.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0):!1}},KQ={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":u.heading}},"TableRow",{name:"TableCell",style:u.content},{name:"TableDelimiter",style:u.processingInstruction}
`);let t=n.textContent.trimEnd(),i="";e!==null&&(i=e.className.replace("language-",""));let r=document.createElement("div");n.parentNode.insertBefore(r,n);let s=Ni({parent:r,doc:t,extensions:FO(r)});new Bt(s).setMode(i,t),n.remove(),tP(s)}function _0(n){let e=n.querySelectorAll("pre");for(let t of e)id(t)}function A0(){let n=document.querySelectorAll(".page-content pre, .comment-box .content pre");for(let e of n)id(e)}function j0(n,e,t,i){let r=Ni({parent:n,doc:t,extensions:FO(n),root:e}),s=new Bt(r);return s.setMode(i,t),s}function G0(n,e){let t=n.textContent,i={parent:n.parentElement,doc:t,extensions:[...Er(n.parentElement),x.updateListener.of(s=>{s.docChanged})]},r=new Bt(Ni(i));return r.setMode(e,t),n.style.display="none",r}function E0(n,e){let t=n.value,i={parent:n.parentElement,doc:t,extensions:[...Er(n.parentElement),x.updateListener.of(O=>{O.docChanged&&(n.value=O.state.doc.toString())})]},r=Ni(i),s=new Bt(r);return s.setMode(e,t),n.style.display="none",s}function I0(n,e,t,i){let r=n.textContent,s={parent:n.parentElement,doc:r,extensions:[dt.of(i),...Er(n.parentElement),x.updateListener.of(o=>{e(o)}),x.domEventHandlers(t)]};window.$events.emitPublic(n,"editor-markdown-cm6::pre-init",{editorViewConfig:s});let O=Ni(s);return new Bt(O).setMode("markdown",""),n.style.display="none",O}export{A0 as highlight,_0 as highlightWithin,E0 as inlineEditor,I0 as markdownEditor,G0 as popupEditor,j0 as wysiwygView};
//# sourceMappingURL=code.js.map