| 251 | `;this.styleTag.textContent=a;let r=A.head||A;this.styleTag.parentNode!=r&&r.insertBefore(this.styleTag,r.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var sC={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:"'"},WB={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HgA=typeof navigator<"u"&&/Mac/.test(navigator.platform),zgA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(lr=0;lr<10;lr++)sC[48+lr]=sC[96+lr]=String(lr);var lr;for(lr=1;lr<=24;lr++)sC[lr+111]="F"+lr;var lr;for(lr=65;lr<=90;lr++)sC[lr]=String.fromCharCode(lr+32),WB[lr]=String.fromCharCode(lr);var lr;for(K6 in sC)WB.hasOwnProperty(K6)||(WB[K6]=sC[K6]);var K6;function zJ(i){var e=HgA&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||zgA&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",A=!e&&i.key||(i.shiftKey?WB:sC)[i.keyCode]||i.key||"Unidentified";return A=="Esc"&&(A="Escape"),A=="Del"&&(A="Delete"),A=="Left"&&(A="ArrowLeft"),A=="Up"&&(A="ArrowUp"),A=="Right"&&(A="ArrowRight"),A=="Down"&&(A="ArrowDown"),A}function po(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,A=arguments[1];if(A&&typeof A=="object"&&A.nodeType==null&&!Array.isArray(A)){for(var t in A)if(Object.prototype.hasOwnProperty.call(A,t)){var n=A[t];typeof n=="string"?i.setAttribute(t,n):n!=null&&(i[t]=n)}e++}for(;e<arguments.length;e++)PJ(i,arguments[e]);return i}function PJ(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var A=0;A<e.length;A++)PJ(i,e[A]);else throw new RangeError("Unsupported child node: "+e)}var Us=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},p9=typeof document<"u"?document:{documentElement:{style:{}}},f9=/Edge\/(\d+)/.exec(Us.userAgent),NY=/MSIE \d/.test(Us.userAgent),m9=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Us.userAgent),E8=!!(NY||m9||f9),jJ=!E8&&/gecko\/(\d+)/i.test(Us.userAgent),l9=!E8&&/Chrome\/(\d+)/.exec(Us.userAgent),VJ="webkitFontSmoothing"in p9.documentElement.style,w9=!E8&&/Apple Computer/.test(Us.vendor),qJ=w9&&(/Mobile\/\w+/.test(Us.userAgent)||Us.maxTouchPoints>2),Ct={mac:qJ||/Mac/.test(Us.platform),windows:/Win/.test(Us.platform),linux:/Linux|X11/.test(Us.platform),ie:E8,ie_version:NY?p9.documentMode||6:m9?+m9[1]:f9?+f9[1]:0,gecko:jJ,gecko_version:jJ?+(/Firefox\/(\d+)/.exec(Us.userAgent)||[0,0])[1]:0,chrome:!!l9,chrome_version:l9?+l9[1]:0,ios:qJ,android:/Android\b/.test(Us.userAgent),webkit:VJ,webkit_version:VJ?+(/\bAppleWebKit\/(\d+)/.exec(Us.userAgent)||[0,0])[1]:0,safari:w9,safari_version:w9?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Us.userAgent)||[0,0])[1]:0,tabSize:p9.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function IS(i,e){for(let A in i)A=="class"&&e.class?e.class+=" "+i.class:A=="style"&&e.style?e.style+=";"+i.style:e[A]=i[A];return e}var $6=Object.create(null);function BS(i,e,A){if(i==e)return!0;i||(i=$6),e||(e=$6);let t=Object.keys(i),n=Object.keys(e);if(t.length-(A&&t.indexOf(A)>-1?1:0)!=n.length-(A&&n.indexOf(A)>-1?1:0))return!1;for(let o of t)if(o!=A&&(n.indexOf(o)==-1||i[o]!==e[o]))return!1;return!0}function PgA(i,e){for(let A=i.attributes.length-1;A>=0;A--){let t=i.attributes[A].name;e[t]==null&&i.removeAttribute(t)}for(let A in e){let t=e[A];A=="style"?i.style.cssText=t:i.getAttribute(A)!=t&&i.setAttribute(A,t)}}function WJ(i,e,A){let t=!1;if(e)for(let n in e)A&&n in A||(t=!0,n=="style"?i.style.cssText="":i.removeAttribute(n));if(A)for(let n in A)e&&e[n]==A[n]||(t=!0,n=="style"?i.style.cssText=A[n]:i.setAttribute(n,A[n]));return t}function jgA(i){let e=Object.create(null);for(let A=0;A<i.attributes.length;A++){let t=i.attributes[A];e[t.name]=t.value}return e}var gl=class{eq(e){return!1}updateDOM(e,A,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,A,t){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},As=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(As||(As={})),Lt=class extends cg{constructor(e,A,t,n){super(),this.startSide=e,this.endSide=A,this.widget=t,this.spec=n}get heightRelevant(){return!1}static mark(e){return new s4(e)}static widget(e){let A=Math.max(-1e4,Math.min(1e4,e.side||0)),t=!!e.block;return A+=t&&!e.inlineOrder?A>0?3e8:-4e8:A>0?1e8:-1e8,new wd(e,A,A,t,e.widget||null,!1)}static replace(e){let A=!!e.block,t,n;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:o,end:a}=FY(e,A);t=(o?A?-3e8:-1:5e8)-1,n=(a?A?2e8:1:-6e8)+1}return new wd(e,t,n,A,e.widget||null,!0)}static line(e){return new l4(e)}static set(e,A=!1){return uo.of(e,A)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Lt.none=uo.empty;var s4=class i extends Lt{constructor(e){let{start:A,end:t}=FY(e);super(A?-1:5e8,t?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?IS(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||$6}eq(e){return this==e||e instanceof i&&this.tagName==e.tagName&&BS(this.attrs,e.attrs)}range(e,A=e){if(e>=A)throw new RangeError("Mark decorations may not be empty");return super.range(e,A)}};s4.prototype.point=!1;var l4=class i extends Lt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&BS(this.spec.attributes,e.spec.attributes)}range(e,A=e){if(A!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,A)}};l4.prototype.mapMode=Wr.TrackBefore;l4.prototype.point=!0;var wd=class i extends Lt{constructor(e,A,t,n,o,a){super(A,t,o,e),this.block=n,this.isReplace=a,this.mapMode=n?A<=0?Wr.TrackBefore:Wr.TrackAfter:Wr.TrackDel}get type(){return this.startSide!=this.endSide?As.WidgetRange:this.startSide<=0?As.WidgetBefore:As.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&VgA(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,A=e){if(this.isReplace&&(e>A||e==A&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&A!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,A)}};wd.prototype.point=!0;function FY(i,e=!1){let{inclusiveStart:A,inclusiveEnd:t}=i;return A==null&&(A=i.inclusive),t==null&&(t=i.inclusive),{start:A??e,end:t??e}}function VgA(i,e){return i==e||!!(i&&e&&i.compare(e))}function th(i,e,A,t=0){let n=A.length-1;n>=0&&A[n]+t>=i?A[n]=Math.max(A[n],e):A.push(i,e)}var A8=class i extends cg{constructor(e,A){super(),this.tagName=e,this.attributes=A}eq(e){return e==this||e instanceof i&&this.tagName==e.tagName&&BS(this.attributes,e.attributes)}static create(e){return new i(e.tagName,e.attributes||$6)}static set(e,A=!1){return uo.of(e,A)}};A8.prototype.startSide=A8.prototype.endSide=-1;function g4(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function y9(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function $u(i,e){if(!e.anchorNode)return!1;try{return y9(i,e.anchorNode)}catch(A){return!1}}function V6(i){return i.nodeType==3?c4(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function A4(i,e,A,t){return A?ZJ(i,e,A,t,-1)||ZJ(i,e,A,t,1):!1}function S2(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function e8(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function ZJ(i,e,A,t,n){for(;;){if(i==A&&e==t)return!0;if(e==(n<0?0:cC(i))){if(i.nodeName=="DIV")return!1;let o=i.parentNode;if(!o||o.nodeType!=1)return!1;e=S2(i)+(n<0?0:1),i=o}else if(i.nodeType==1){if(i=i.childNodes[e+(n<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=n<0?cC(i):0}else return!1}}function cC(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function t8(i,e){let A=e?i.left:i.right;return{left:A,right:A,top:i.top,bottom:i.bottom}}function qgA(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function LY(i,e){let A=e.width/i.offsetWidth,t=e.height/i.offsetHeight;return(A>.995&&A<1.005||!isFinite(A)||Math.abs(e.width-i.offsetWidth)<1)&&(A=1),(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.height-i.offsetHeight)<1)&&(t=1),{scaleX:A,scaleY:t}}function WgA(i,e,A,t,n,o,a,r){let s=i.ownerDocument,l=s.defaultView||window;for(let g=i,C=!1;g&&!C;)if(g.nodeType==1){let d,B=g==s.body,u=1,E=1;if(B)d=qgA(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(C=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let v=g.getBoundingClientRect();({scaleX:u,scaleY:E}=LY(g,v)),d={left:v.left,right:v.left+g.clientWidth*u,top:v.top,bottom:v.top+g.clientHeight*E}}let f=0,m=0;if(n=="nearest")e.top<d.top?(m=e.top-(d.top+a),A>0&&e.bottom>d.bottom+m&&(m=e.bottom-d.bottom+a)):e.bottom>d.bottom&&(m=e.bottom-d.bottom+a,A<0&&e.top-m<d.top&&(m=e.top-(d.top+a)));else{let v=e.bottom-e.top,S=d.bottom-d.top;m=(n=="center"&&v<=S?e.top+v/2-S/2:n=="start"||n=="center"&&A<0?e.top-a:e.bottom-S+a)-d.top}if(t=="nearest"?e.left<d.left?(f=e.left-(d.left+o),A>0&&e.right>d.right+f&&(f=e.right-d.right+o)):e.right>d.right&&(f=e.right-d.right+o,A<0&&e.left<d.left+f&&(f=e.left-(d.left+o))):f=(t=="center"?e.left+(e.right-e.left)/2-(d.right-d.left)/2:t=="start"==r?e.left-o:e.right-(d.right-d.left)+o)-d.left,f||m)if(B)l.scrollBy(f,m);else{let v=0,S=0;if(m){let k=g.scrollTop;g.scrollTop+=m/E,S=(g.scrollTop-k)*E}if(f){let k=g.scrollLeft;g.scrollLeft+=f/u,v=(g.scrollLeft-k)*u}e={left:e.left-v,top:e.top-S,right:e.right-v,bottom:e.bottom-S},v&&Math.abs(v-f)<1&&(t="nearest"),S&&Math.abs(S-m)<1&&(n="nearest")}if(B)break;(e.top<d.top||e.bottom>d.bottom||e.left<d.left||e.right>d.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function GY(i,e=!0){let A=i.ownerDocument,t=null,n=null;for(let o=i.parentNode;o&&!(o==A.body||(!e||t)&&n);)if(o.nodeType==1)!n&&o.scrollHeight>o.clientHeight&&(n=o),e&&!t&&o.scrollWidth>o.clientWidth&&(t=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:t,y:n}}var D9=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:A,focusNode:t}=e;this.set(A,Math.min(e.anchorOffset,A?cC(A):0),t,Math.min(e.focusOffset,t?cC(t):0))}set(e,A,t,n){this.anchorNode=e,this.anchorOffset=A,this.focusNode=t,this.focusOffset=n}},pd=null;Ct.safari&&Ct.safari_version>=26&&(pd=!1);function KY(i){if(i.setActive)return i.setActive();if(pd)return i.focus(pd);let e=[];for(let A=i;A&&(e.push(A,A.scrollTop,A.scrollLeft),A!=A.ownerDocument);A=A.parentNode);if(i.focus(pd==null?{get preventScroll(){return pd={preventScroll:!0},!0}}:void 0),!pd){pd=!1;for(let A=0;A<e.length;){let t=e[A++],n=e[A++],o=e[A++];t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=o&&(t.scrollLeft=o)}}}var XJ;function c4(i,e,A=e){let t=XJ||(XJ=document.createRange());return t.setEnd(i,A),t.setStart(i,e),t}function ih(i,e,A,t){let n={key:e,code:e,keyCode:A,which:A,cancelable:!0};t&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=t);let o=new KeyboardEvent("keydown",n);o.synthetic=!0,i.dispatchEvent(o);let a=new KeyboardEvent("keyup",n);return a.synthetic=!0,i.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function ZgA(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function XgA(i,e){let A=e.focusNode,t=e.focusOffset;if(!A||e.anchorNode!=A||e.anchorOffset!=t)return!1;for(t=Math.min(t,cC(A));;)if(t){if(A.nodeType!=1)return!1;let n=A.childNodes[t-1];n.contentEditable=="false"?t--:(A=n,t=cC(A))}else{if(A==i)return!0;t=S2(A),A=A.parentNode}}function UY(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function TY(i,e){for(let A=i,t=e;;){if(A.nodeType==3&&t>0)return{node:A,offset:t};if(A.nodeType==1&&t>0){if(A.contentEditable=="false")return null;A=A.childNodes[t-1],t=cC(A)}else if(A.parentNode&&!e8(A))t=S2(A),A=A.parentNode;else return null}}function OY(i,e){for(let A=i,t=e;;){if(A.nodeType==3&&t<A.nodeValue.length)return{node:A,offset:t};if(A.nodeType==1&&t<A.childNodes.length){if(A.contentEditable=="false")return null;A=A.childNodes[t],t=0}else if(A.parentNode&&!e8(A))t=S2(A)+1,A=A.parentNode;else return null}}var C0=class i{constructor(e,A,t=!0){this.node=e,this.offset=A,this.precise=t}static before(e,A){return new i(e.parentNode,S2(e),A)}static after(e,A){return new i(e.parentNode,S2(e)+1,A)}},Lo=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(Lo||(Lo={})),yd=Lo.LTR,hS=Lo.RTL;function JY(i){let e=[];for(let A=0;A<i.length;A++)e.push(1<<+i[A]);return e}var $gA=JY("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),AcA=JY("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),v9=Object.create(null),c0=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),A=i.charCodeAt(1);v9[e]=A,v9[A]=-e}function YY(i){return i<=247?$gA[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?AcA[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}var ecA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Bg=class{get dir(){return this.level%2?hS:yd}constructor(e,A,t){this.from=e,this.to=A,this.level=t}side(e,A){return this.dir==A==e?this.to:this.from}forward(e,A){return e==(this.dir==A)}static find(e,A,t,n){let o=-1;for(let a=0;a<e.length;a++){let r=e[a];if(r.from<=A&&r.to>=A){if(r.level==t)return a;(o<0||(n!=0?n<0?r.from<A:r.to>A:e[o].level>r.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}};function HY(i,e){if(i.length!=e.length)return!1;for(let A=0;A<i.length;A++){let t=i[A],n=e[A];if(t.from!=n.from||t.to!=n.to||t.direction!=n.direction||!HY(t.inner,n.inner))return!1}return!0}var la=[];function tcA(i,e,A,t,n){for(let o=0;o<=t.length;o++){let a=o?t[o-1].to:e,r=o<t.length?t[o].from:A,s=o?256:n;for(let l=a,g=s,C=s;l<r;l++){let d=YY(i.charCodeAt(l));d==512?d=g:d==8&&C==4&&(d=16),la[l]=d==4?2:d,d&7&&(C=d),g=d}for(let l=a,g=s,C=s;l<r;l++){let d=la[l];if(d==128)l<r-1&&g==la[l+1]&&g&24?d=la[l]=g:la[l]=256;else if(d==64){let B=l+1;for(;B<r&&la[B]==64;)B++;let u=l&&g==8||B<A&&la[B]==8?C==1?1:8:256;for(let E=l;E<B;E++)la[E]=u;l=B-1}else d==8&&C==1&&(la[l]=1);g=d,d&7&&(C=d)}}}function icA(i,e,A,t,n){let o=n==1?2:1;for(let a=0,r=0,s=0;a<=t.length;a++){let l=a?t[a-1].to:e,g=a<t.length?t[a].from:A;for(let C=l,d,B,u;C<g;C++)if(B=v9[d=i.charCodeAt(C)])if(B<0){for(let E=r-3;E>=0;E-=3)if(c0[E+1]==-B){let f=c0[E+2],m=f&2?n:f&4?f&1?o:n:0;m&&(la[C]=la[c0[E]]=m),r=E;break}}else{if(c0.length==189)break;c0[r++]=C,c0[r++]=d,c0[r++]=s}else if((u=la[C])==2||u==1){let E=u==n;s=E?0:1;for(let f=r-3;f>=0;f-=3){let m=c0[f+2];if(m&2)break;if(E)c0[f+2]|=2;else{if(m&4)break;c0[f+2]|=4}}}}}function ncA(i,e,A,t){for(let n=0,o=t;n<=A.length;n++){let a=n?A[n-1].to:i,r=n<A.length?A[n].from:e;for(let s=a;s<r;){let l=la[s];if(l==256){let g=s+1;for(;;)if(g==r){if(n==A.length)break;g=A[n++].to,r=n<A.length?A[n].from:e}else if(la[g]==256)g++;else break;let C=o==1,d=(g<e?la[g]:t)==1,B=C==d?C?1:2:t;for(let u=g,E=n,f=E?A[E-1].to:i;u>s;)u==f&&(u=A[--E].from,f=E?A[E-1].to:i),la[--u]=B;s=g}else o=l,s++}}}function b9(i,e,A,t,n,o,a){let r=t%2?2:1;if(t%2==n%2)for(let s=e,l=0;s<A;){let g=!0,C=!1;if(l==o.length||s<o[l].from){let E=la[s];E!=r&&(g=!1,C=E==16)}let d=!g&&r==1?[]:null,B=g?t:t+1,u=s;A:for(;;)if(l<o.length&&u==o[l].from){if(C)break A;let E=o[l];if(!g)for(let f=E.to,m=l+1;;){if(f==A)break A;if(m<o.length&&o[m].from==f)f=o[m++].to;else{if(la[f]==r)break A;break}}if(l++,d)d.push(E);else{E.from>s&&a.push(new Bg(s,E.from,B));let f=E.direction==yd!=!(B%2);M9(i,f?t+1:t,n,E.inner,E.from,E.to,a),s=E.to}u=E.to}else{if(u==A||(g?la[u]!=r:la[u]==r))break;u++}d?b9(i,s,u,t+1,n,d,a):s<u&&a.push(new Bg(s,u,B)),s=u}else for(let s=A,l=o.length;s>e;){let g=!0,C=!1;if(!l||s>o[l-1].to){let E=la[s-1];E!=r&&(g=!1,C=E==16)}let d=!g&&r==1?[]:null,B=g?t:t+1,u=s;A:for(;;)if(l&&u==o[l-1].to){if(C)break A;let E=o[--l];if(!g)for(let f=E.from,m=l;;){if(f==e)break A;if(m&&o[m-1].to==f)f=o[--m].from;else{if(la[f-1]==r)break A;break}}if(d)d.push(E);else{E.to<s&&a.push(new Bg(E.to,s,B));let f=E.direction==yd!=!(B%2);M9(i,f?t+1:t,n,E.inner,E.from,E.to,a),s=E.from}u=E.from}else{if(u==e||(g?la[u-1]!=r:la[u-1]==r))break;u--}d?b9(i,u,s,t+1,n,d,a):u<s&&a.push(new Bg(u,s,B)),s=u}}function M9(i,e,A,t,n,o,a){let r=e%2?2:1;tcA(i,n,o,t,r),icA(i,n,o,t,r),ncA(n,o,t,r),b9(i,n,o,e,A,t,a)}function ocA(i,e,A){if(!i)return[new Bg(0,0,e==hS?1:0)];if(e==yd&&!A.length&&!ecA.test(i))return zY(i.length);if(A.length)for(;i.length>la.length;)la[la.length]=256;let t=[],n=e==yd?0:1;return M9(i,n,n,A,0,i.length,t),t}function zY(i){return[new Bg(0,i,0)]}var PY="";function acA(i,e,A,t,n){var o;let a=t.head-i.from,r=Bg.find(e,a,(o=t.bidiLevel)!==null&&o!==void 0?o:-1,t.assoc),s=e[r],l=s.side(n,A);if(a==l){let d=r+=n?1:-1;if(d<0||d>=e.length)return null;s=e[r=d],a=s.side(!n,A),l=s.side(n,A)}let g=tr(i.text,a,s.forward(n,A));(g<s.from||g>s.to)&&(g=l),PY=i.text.slice(Math.min(a,g),Math.max(a,g));let C=r==(n?e.length-1:0)?null:e[r+(n?1:-1)];return C&&g==l&&C.level+(n?0:1)<s.level?Be.cursor(C.side(!n,A)+i.from,C.forward(n,A)?1:-1,C.level):Be.cursor(g+i.from,s.forward(n,A)?-1:1,s.level)}function rcA(i,e,A){for(let t=e;t<A;t++){let n=YY(i.charCodeAt(t));if(n==1)return yd;if(n==2||n==4)return hS}return yd}var jY=nt.define(),VY=nt.define(),qY=nt.define(),WY=nt.define(),g9=nt.define(),ZY=nt.define(),XY=nt.define(),ES=nt.define(),QS=nt.define(),$J=nt.define({combine:i=>i.some(e=>e)}),$Y=nt.define({combine:i=>i.some(e=>e)}),AH=nt.define(),e4=class i{constructor(e,A="nearest",t="nearest",n=5,o=5,a=!1){this.range=e,this.y=A,this.x=t,this.yMargin=n,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(Be.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},U6=ln.define({map:(i,e)=>i.map(e)}),eH=ln.define();function Gr(i,e,A){let t=i.facet(WY);t.length?t[0](e):window.onerror&&window.onerror(String(e),A,void 0,void 0,e)||(A?console.error(A+":",e):console.error(e))}var lC=nt.define({combine:i=>i.length?i[0]:!0}),scA=0,XB=nt.define({combine(i){return i.filter((e,A)=>{for(let t=0;t<A;t++)if(i[t].plugin==e.plugin)return!1;return!0})}}),Po=class i{constructor(e,A,t,n,o){this.id=e,this.create=A,this.domEventHandlers=t,this.domEventObservers=n,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(XB.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(XB.of({plugin:this,arg:e}))}static define(e,A){let{eventHandlers:t,eventObservers:n,provide:o,decorations:a}=A||{};return new i(scA++,e,t,n,r=>{let s=[];return a&&s.push(Q8.of(l=>{let g=l.plugin(r);return g?a(g):Lt.none})),o&&s.push(o(r)),s})}static fromClass(e,A){return i.define((t,n)=>new e(t,n),A)}},t4=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let A=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(A)}catch(t){if(Gr(A.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(n){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(A){Gr(e.state,A,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var A;if(!((A=this.value)===null||A===void 0)&&A.destroy)try{this.value.destroy()}catch(t){Gr(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},AY=nt.define(),S9=nt.define(),Q8=nt.define(),tH=nt.define(),uS=nt.define(),C4=nt.define(),iH=nt.define();function eY(i,e){let A=i.state.facet(iH);if(!A.length)return A;let t=A.map(o=>o instanceof Function?o(i):o),n=[];return uo.spans(t,e.from,e.to,{point(){},span(o,a,r,s){let l=o-e.from,g=a-e.from,C=n;for(let d=r.length-1;d>=0;d--,s--){let B=r[d].spec.bidiIsolate,u;if(B==null&&(B=rcA(e.text,l,g)),s>0&&C.length&&(u=C[C.length-1]).to==l&&u.direction==B)u.to=g,C=u.inner;else{let E={from:l,to:g,direction:B,inner:[]};C.push(E),C=E.inner}}}}),n}var nH=nt.define();function pS(i){let e=0,A=0,t=0,n=0;for(let o of i.state.facet(nH)){let a=o(i);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(A=Math.max(A,a.right)),a.top!=null&&(t=Math.max(t,a.top)),a.bottom!=null&&(n=Math.max(n,a.bottom)))}return{left:e,right:A,top:t,bottom:n}}var Wu=nt.define(),rc=class i{constructor(e,A,t,n){this.fromA=e,this.toA=A,this.fromB=t,this.toB=n}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let A=e.length,t=this;for(;A>0;A--){let n=e[A-1];if(!(n.fromA>t.toA)){if(n.toA<t.fromA)break;t=t.join(n),e.splice(A-1,1)}}return e.splice(A,0,t),e}static extendWithRanges(e,A){if(A.length==0)return e;let t=[];for(let n=0,o=0,a=0;;){let r=n<e.length?e[n].fromB:1e9,s=o<A.length?A[o]:1e9,l=Math.min(r,s);if(l==1e9)break;let g=l+a,C=l,d=g;for(;;)if(o<A.length&&A[o]<=C){let B=A[o+1];o+=2,C=Math.max(C,B);for(let u=n;u<e.length&&e[u].fromB<=C;u++)a=e[u].toA-e[u].toB;d=Math.max(d,B+a)}else if(n<e.length&&e[n].fromB<=C){let B=e[n++];C=Math.max(C,B.toB),d=Math.max(d,B.toA),a=B.toA-B.toB}else break;t.push(new i(g,d,l,C))}return t}},i8=class i{constructor(e,A,t){this.view=e,this.state=A,this.transactions=t,this.flags=0,this.startState=e.state,this.changes=Zr.empty(this.startState.doc.length);for(let o of t)this.changes=this.changes.compose(o.changes);let n=[];this.changes.iterChangedRanges((o,a,r,s)=>n.push(new rc(o,a,r,s))),this.changedRanges=n}static create(e,A,t){return new i(e,A,t)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},lcA=[],_a=class{constructor(e,A,t=0){this.dom=e,this.length=A,this.flags=t,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return lcA}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let A=this.domAttrs;A&&PgA(this.dom,A)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,A=this.posAtStart){let t=A;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,A){return null}domPosFor(e,A){let t=S2(this.dom),n=this.length?e>0:A>0;return new C0(this.parent.dom,t+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof oh)return e;return null}static get(e){return e.cmTile}},nh=class extends _a{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let A=this.dom,t=null,n,o=e?.node==A?e:null,a=0;for(let r of this.children){if(r.sync(e),a+=r.length+r.breakAfter,n=t?t.nextSibling:A.firstChild,o&&n!=r.dom&&(o.written=!0),r.dom.parentNode==A)for(;n&&n!=r.dom;)n=tY(n);else A.insertBefore(r.dom,n);t=r.dom}for(n=t?t.nextSibling:A.firstChild,o&&n&&(o.written=!0);n;)n=tY(n);this.length=a}};function tY(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var oh=class extends nh{constructor(e,A){super(A),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let A=_a.get(e);if(A&&this.owns(A))return A;e=e.parentNode}}blockTiles(e){for(let A=[],t=this,n=0,o=0;;)if(n==t.children.length){if(!A.length)return;t=t.parent,t.breakAfter&&o++,n=A.pop()}else{let a=t.children[n++];if(a instanceof gC)A.push(n),t=a,n=0;else{let r=o+a.length,s=e(a,o);if(s!==void 0)return s;o=r+a.breakAfter}}}resolveBlock(e,A){let t,n=-1,o,a=-1;if(this.blockTiles((r,s)=>{let l=s+r.length;if(e>=s&&e<=l){if(r.isWidget()&&A>=-1&&A<=1){if(r.flags&32)return!0;r.flags&16&&(t=void 0)}(s<e||e==l&&(A<-1?r.length:r.covers(1)))&&(!t||!r.isWidget()&&t.isWidget())&&(t=r,n=e-s),(l>e||e==s&&(A>1?r.length:r.covers(-1)))&&(!o||!r.isWidget()&&o.isWidget())&&(o=r,a=e-s)}}),!t&&!o)throw new Error("No tile at position "+e);return t&&A<0||!o?{tile:t,offset:n}:{tile:o,offset:a}}},gC=class i extends nh{constructor(e,A){super(e),this.wrapper=A}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,A){let t=new i(A||document.createElement(e.tagName),e);return A||(t.flags|=4),t}},ah=class i extends nh{constructor(e,A){super(e),this.attrs=A}isLine(){return!0}static start(e,A,t){let n=new i(A||document.createElement("div"),e);return(!A||!t)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,A,t){let n=null,o=-1,a=null,r=-1;function s(g,C){for(let d=0,B=0;d<g.children.length&&B<=C;d++){let u=g.children[d],E=B+u.length;E>=C&&(u.isComposite()?s(u,C-B):(!a||a.isHidden&&(A>0||t&&ccA(a,u)))&&(E>C||u.flags&32)?(a=u,r=C-B):(B<C||u.flags&16&&!u.isHidden)&&(n=u,o=C-B)),B=E}}s(this,e);let l=(A<0?n:a)||n||a;return l?{tile:l,offset:l==n?o:r}:null}coordsIn(e,A){let t=this.resolveInline(e,A,!0);return t?t.tile.coordsIn(Math.max(0,t.offset),A):gcA(this)}domIn(e,A){let t=this.resolveInline(e,A);if(t){let{tile:n,offset:o}=t;if(this.dom.contains(n.dom))return n.isText()?new C0(n.dom,Math.min(n.dom.nodeValue.length,o)):n.domPosFor(o,n.flags&16?1:n.flags&32?-1:A);let a=t.tile.parent,r=!1;for(let s of a.children){if(r)return new C0(s.dom,0);s==t.tile&&(r=!0)}}return new C0(this.dom,0)}};function gcA(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let A=V6(e);return A[A.length-1]||null}function ccA(i,e){let A=i.coordsIn(0,1),t=e.coordsIn(0,1);return A&&t&&t.top<A.bottom}var ll=class i extends nh{constructor(e,A){super(e),this.mark=A}get domAttrs(){return this.mark.attrs}static of(e,A){let t=new i(A||document.createElement(e.tagName),e);return A||(t.flags|=4),t}},fd=class i extends _a{constructor(e,A){super(e,A.length),this.text=A}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,A){let t=this.dom.nodeValue.length;e>t&&(e=t);let n=e,o=e,a=0;e==0&&A<0||e==t&&A>=0?Ct.chrome||Ct.gecko||(e?(n--,a=1):o<t&&(o++,a=-1)):A<0?n--:o<t&&o++;let r=c4(this.dom,n,o).getClientRects();if(!r.length)return null;let s=r[(a?a<0:A>=0)?0:r.length-1];return Ct.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(r,l=>l.width)||s),a?t8(s,a<0):s||null}static of(e,A){let t=new i(A||document.createTextNode(e),e);return A||(t.flags|=2),t}},Dd=class i extends _a{constructor(e,A,t,n){super(e,A,n),this.widget=t}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,A){return this.coordsInWidget(e,A,!1)}coordsInWidget(e,A,t){let n=this.widget.coordsAt(this.dom,e,A);if(n)return n;if(t)return t8(this.dom.getBoundingClientRect(),this.length?e==0:A<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let s=r?o.length-1:0;a=o[s],!(e>0?s==0:s==o.length-1||a.top<a.bottom);s+=r?-1:1);return t8(a,!r)}}get overrideDOMText(){if(!this.length)return On.empty;let{root:e}=this;if(!e)return On.empty;let A=this.posAtStart;return e.view.state.doc.slice(A,A+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,A,t,n,o){return o||(o=e.toDOM(A),e.editable||(o.contentEditable="false")),new i(o,t,e,n)}},rh=class extends _a{constructor(e){let A=document.createElement("img");A.className="cm-widgetBuffer",A.setAttribute("aria-hidden","true"),super(A,0,e)}get isHidden(){return!0}get overrideDOMText(){return On.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},k9=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,A,t){let{tile:n,index:o,beforeBreak:a,parents:r}=this;for(;e||A>0;)if(n.isComposite())if(a){if(!e)break;t&&t.break(),e--,a=!1}else if(o==n.children.length){if(!e&&!r.length)break;t&&t.leave(n),a=!!n.breakAfter,{tile:n,index:o}=r.pop(),o++}else{let s=n.children[o],l=s.breakAfter;(A>0?s.length<=e:s.length<e)&&(!t||t.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!l,o++,e-=s.length):(r.push({tile:n,index:o}),n=s,o=0,t&&s.isComposite()&&t.enter(s))}else if(o==n.length)a=!!n.breakAfter,{tile:n,index:o}=r.pop(),o++;else if(e){let s=Math.min(e,n.length-o);t&&t.skip(n,o,o+s),e-=s,o+=s}else break;return this.tile=n,this.index=o,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},_9=class{constructor(e,A,t,n){this.from=e,this.to=A,this.wrapper=t,this.rank=n}},x9=class{constructor(e,A,t){this.cache=e,this.root=A,this.blockWrappers=t,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,A,t,n){var o;this.flushBuffer();let a=this.ensureMarks(A,t),r=a.lastChild;if(r&&r.isText()&&!(r.flags&8)&&r.length+e.length<512){this.cache.reused.set(r,2);let s=a.children[a.children.length-1]=new fd(r.dom,r.text+e);s.parent=a}else a.append(n||fd.of(e,(o=this.cache.find(fd))===null||o===void 0?void 0:o.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,A){let t=this.curLine;t.dom!=A.line.dom&&(t.setDOM(this.cache.reused.has(A.line)?c9(A.line.dom):A.line.dom),this.cache.reused.set(A.line,2));let n=t;for(let r=A.marks.length-1;r>=0;r--){let s=A.marks[r],l=n.lastChild;if(l instanceof ll&&l.mark.eq(s.mark))l.dom!=s.dom&&l.setDOM(c9(s.dom)),n=l;else{if(this.cache.reused.get(s)){let C=_a.get(s.dom);C&&C.setDOM(c9(s.dom))}let g=ll.of(s.mark,s.dom);n.append(g),n=g}this.cache.reused.set(s,2)}let o=_a.get(e.text);o&&this.cache.reused.set(o,2);let a=new fd(e.text,e.text.nodeValue);a.flags|=8,n.append(a)}addInlineWidget(e,A,t){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let o=this.ensureMarks(A,t);!n&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,A,t){this.flushBuffer(),this.ensureMarks(A,t).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let A=this.afterWidget||this.lastBlock;A.length+=e,this.pos+=e}addLineStart(e,A){var t;e||(e=oH);let n=ah.start(e,A||((t=this.cache.find(ah))===null||t===void 0?void 0:t.dom),!!A);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,A){var t;let n=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],r;if(A>0&&(r=n.lastChild)&&r instanceof ll&&r.mark.eq(a))n=r,A--;else{let s=ll.of(a,(t=this.cache.find(ll,l=>l.mark.eq(a)))===null||t===void 0?void 0:t.dom);n.append(s),n=s,A=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!iY(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ct.ios&&iY(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(C9,0,32)||new Dd(C9.toDOM(),0,C9,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let A=new _9(e.from,e.to,e.value,e.rank),t=this.wrappers.length;for(;t>0&&(this.wrappers[t-1].rank-A.rank||this.wrappers[t-1].to-A.to)<0;)t--;this.wrappers.splice(t,0,A)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let A=this.root;for(let t of this.wrappers){let n=A.lastChild;if(t.from<this.pos&&n instanceof gC&&n.wrapper.eq(t.wrapper))A=n;else{let o=gC.of(t.wrapper,(e=this.cache.find(gC,a=>a.wrapper.eq(t.wrapper)))===null||e===void 0?void 0:e.dom);A.append(o),A=o}}return A}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let A=2|(e<0?16:32),t=this.cache.find(rh,void 0,1);return t&&(t.flags=A),t||new rh(A)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},R9=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:n,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=n;let r=this.textOff=Math.min(e,n.length);return o?null:n.slice(0,r)}let A=Math.min(this.text.length,this.textOff+e),t=this.text.slice(this.textOff,A);return this.textOff=A,t}},n8=[Dd,ah,fd,ll,rh,gC,oh];for(let i=0;i<n8.length;i++)n8[i].bucket=i;var N9=class{constructor(e){this.view=e,this.buckets=n8.map(()=>[]),this.index=n8.map(()=>0),this.reused=new Map}add(e){let A=e.constructor.bucket,t=this.buckets[A];t.length<6?t.push(e):t[this.index[A]=(this.index[A]+1)%6]=e}find(e,A,t=2){let n=e.bucket,o=this.buckets[n],a=this.index[n];for(let r=o.length-1;r>=0;r--){let s=(r+a)%o.length,l=o[s];if((!A||A(l))&&!this.reused.has(l))return o.splice(s,1),s<a&&this.index[n]--,this.reused.set(l,t),l}return null}findWidget(e,A,t){let n=this.buckets[0];if(n.length)for(let o=0,a=0;;o++){if(o==n.length){if(a)return null;a=1,o=0}let r=n[o];if(!this.reused.has(r)&&(a==0?r.widget.compare(e):r.widget.constructor==e.constructor&&e.updateDOM(r.dom,this.view,r.widget)))return n.splice(o,1),o<this.index[0]&&this.index[0]--,r.widget==e&&r.length==A&&(r.flags&497)==t?(this.reused.set(r,1),r):(this.reused.set(r,2),new Dd(r.dom,A,e,r.flags&-498|t))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,A=2){if(!this.reused.has(e))return this.reused.set(e,A),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},F9=class{constructor(e,A,t,n,o){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=o,this.openWidget=!1,this.openMarks=0,this.cache=new N9(e),this.text=new R9(e.state.doc),this.builder=new x9(this.cache,new oh(e,e.contentDOM),uo.iter(t)),this.cache.reused.set(A,2),this.old=new k9(A),this.reuseWalker={skip:(a,r,s)=>{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,A){let t=A&&this.getCompositionContext(A.text);for(let n=0,o=0,a=0;;){let r=a<e.length?e[a++]:null,s=r?r.fromA:this.old.root.length;if(s>n){let l=s-n;this.preserve(l,!a,!r),n=s,o+=l}if(!r)break;A&&r.fromA<=A.range.fromA&&r.toA>=A.range.toA?(this.forward(r.fromA,A.range.fromA,A.range.fromA<A.range.toA?1:-1),this.emit(o,A.range.fromB),this.cache.clear(),this.builder.addComposition(A,t),this.text.skip(A.range.toB-A.range.fromB),this.forward(A.range.fromA,r.toA),this.emit(A.range.toB,r.toB)):(this.forward(r.fromA,r.toA),this.emit(o,r.toB)),o=r.toB,n=r.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,A,t){let n=IcA(this.old),o=this.openMarks;this.old.advance(e,t?1:-1,{skip:(a,r,s)=>{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(s-r);else{let l=s>0||r<a.length?Dd.of(a.widget,this.view,s-r,a.flags&496,this.cache.maybeReuse(a)):this.cache.reuse(a);l.flags&256?(l.flags&=-2,this.builder.addBlockWidget(l)):(this.builder.ensureLine(null),this.builder.addInlineWidget(l,n,o),o=n.length)}else if(a.isText())this.builder.ensureLine(null),!r&&s==a.length&&!this.cache.reused.has(a)?this.builder.addText(a.text,n,o,this.cache.reuse(a)):(this.cache.add(a),this.builder.addText(a.text.slice(r,s),n,o)),o=n.length;else if(a.isLine())a.flags&=-2,this.cache.reused.set(a,1),this.builder.addLine(a);else if(a instanceof rh)this.cache.add(a);else if(a instanceof ll)this.builder.ensureLine(null),this.builder.addMark(a,n,o),this.cache.reused.set(a,1),o=n.length;else return!1;this.openWidget=!1},enter:a=>{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof ll&&n.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?n.length&&(n.length=o=0):a instanceof ll&&(n.shift(),o=Math.min(o,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,A){let t=null,n=this.builder,o=0,a=uo.spans(this.decorations,e,A,{point:(r,s,l,g,C,d)=>{if(l instanceof wd){if(this.disallowBlockEffectsFor[d]){if(l.block)throw new RangeError("Block decorations may not be specified via plugins");if(s>this.view.state.doc.lineAt(r).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=g.length,C>g.length)n.continueWidget(s-r);else{let B=l.widget||(l.block?nY.block:nY.inline),u=CcA(l),E=this.cache.findWidget(B,s-r,u)||Dd.of(B,this.view,s-r,u);l.block?(l.startSide>0&&n.addLineStartIfNotCovered(t),n.addBlockWidget(E)):(n.ensureLine(t),n.addInlineWidget(E,g,C))}t=null}else t=dcA(t,l);s>r&&this.text.skip(s-r)},span:(r,s,l,g)=>{for(let C=r;C<s;){let d=this.text.next(Math.min(512,s-C));d==null?(n.addLineStartIfNotCovered(t),n.addBreak(),C++):(n.ensureLine(t),n.addText(d,l,C==r?g:l.length),C+=d.length),t=null}}});n.addLineStartIfNotCovered(t),this.openWidget=a>o,this.openMarks=a}forward(e,A,t=1){A-e<=10?this.old.advance(A-e,t,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(A-e-10,-1),this.old.advance(5,t,this.reuseWalker))}getCompositionContext(e){let A=[],t=null;for(let n=e.parentNode;;n=n.parentNode){let o=_a.get(n);if(n==this.view.contentDOM)break;o instanceof ll?A.push(o):o?.isLine()?t=o:o instanceof gC||(n.nodeName=="DIV"&&!t&&n!=this.view.contentDOM?t=new ah(n,oH):t||A.push(ll.of(new s4({tagName:n.nodeName.toLowerCase(),attributes:jgA(n)}),n)))}return{line:t,marks:A}}};function iY(i,e){let A=t=>{for(let n of t.children)if((e?n.isText():n.length)||A(n))return!0;return!1};return A(i)}function CcA(i){let e=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(e|=256),e}var oH={class:"cm-line"};function dcA(i,e){let A=e.spec.attributes,t=e.spec.class;return!A&&!t||(i||(i={class:"cm-line"}),A&&IS(A,i),t&&(i.class+=" "+t)),i}function IcA(i){let e=[];for(let A=i.parents.length;A>1;A--){let t=A==i.parents.length?i.tile:i.parents[A].tile;t instanceof ll&&e.push(t.mark)}return e}function c9(i){let e=_a.get(i);return e&&e.setDOM(i.cloneNode()),i}var nY=(()=>{class i extends gl{constructor(A){super(),this.tag=A}eq(A){return A.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(A){return A.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}return i.inline=new i("span"),i.block=new i("div"),i})(),C9=new class extends gl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},o8=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Lt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new oh(e,e.contentDOM),this.updateInner([new rc(0,0,0,e.state.doc.length)],null)}update(e){var A;let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:g,toA:C})=>C<this.minWidthFrom||g>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((A=this.domChanged)===null||A===void 0)&&A.newSel?n=this.domChanged.newSel.head:!mcA(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let o=n>-1?hcA(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:C}=this.hasComposition;t=new rc(g,C,e.changes.mapPos(g,-1),e.changes.mapPos(C,1)).addToSet(t.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Ct.ie||Ct.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,r=this.blockWrappers;this.updateDeco();let s=ucA(a,this.decorations,e.changes);s.length&&(t=rc.extendWithRanges(t,s));let l=pcA(r,this.blockWrappers,e.changes);return l.length&&(t=rc.extendWithRanges(t,l)),o&&!t.some(g=>g.fromA<=o.range.fromA&&g.toA>=o.range.toA)&&(t=o.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,A){this.view.viewState.mustMeasureContent=!0;let{observer:t}=this.view;t.ignore(()=>{if(A||e.length){let a=this.tile,r=new F9(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);A&&_a.get(A.text)&&r.cache.reused.set(_a.get(A.text),2),this.tile=r.run(e,A),L9(a,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Ct.chrome||Ct.ios?{node:t.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||t.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.tile.children)o.isWidget()&&o.widget instanceof i4&&n.push(o.dom);t.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let A of e.transactions)for(let t of A.effects)t.is(eH)&&(this.editContextFormatting=t.value)}updateSelection(e=!1,A=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:t}=this.tile,n=this.view.root.activeElement,o=n==t,a=!o&&!(this.view.state.facet(lC)||t.tabIndex>-1)&&$u(t,this.view.observer.selectionRange)&&!(n&&t.contains(n));if(!(o||A||a))return;let r=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,l,g;if(s.empty?g=l=this.inlineDOMNearPos(s.anchor,s.assoc||1):(g=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),l=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Ct.gecko&&s.empty&&!this.hasComposition&&BcA(l)){let d=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(d,l.node.childNodes[l.offset]||null)),l=g=new C0(d,0),r=!0}let C=this.view.observer.selectionRange;(r||!C.focusNode||(!A4(l.node,l.offset,C.anchorNode,C.anchorOffset)||!A4(g.node,g.offset,C.focusNode,C.focusOffset))&&!this.suppressWidgetCursorChange(C,s))&&(this.view.observer.ignore(()=>{Ct.android&&Ct.chrome&&t.contains(C.focusNode)&&fcA(C.focusNode,t)&&(t.blur(),t.focus({preventScroll:!0}));let d=g4(this.view.root);if(d)if(s.empty){if(Ct.gecko){let B=EcA(l.node,l.offset);if(B&&B!=3){let u=(B==1?TY:OY)(l.node,l.offset);u&&(l=new C0(u.node,u.offset))}}d.collapse(l.node,l.offset),s.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=s.bidiLevel)}else if(d.extend){d.collapse(l.node,l.offset);try{d.extend(g.node,g.offset)}catch(B){}}else{let B=document.createRange();s.anchor>s.head&&([l,g]=[g,l]),B.setEnd(g.node,g.offset),B.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(B)}a&&this.view.root.activeElement==t&&(t.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,g)),this.impreciseAnchor=l.precise?null:new C0(C.anchorNode,C.anchorOffset),this.impreciseHead=g.precise?null:new C0(C.focusNode,C.focusOffset)}suppressWidgetCursorChange(e,A){return this.hasComposition&&A.empty&&A4(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==A.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,A=e.state.selection.main,t=g4(e.root),{anchorNode:n,anchorOffset:o}=e.observer.selectionRange;if(!t||!A.empty||!A.assoc||!t.modify)return;let a=this.lineAt(A.head,A.assoc);if(!a)return;let r=a.posAtStart;if(A.head==r||A.head==r+a.length)return;let s=this.coordsAt(A.head,-1),l=this.coordsAt(A.head,1);if(!s||!l||s.bottom>l.top)return;let g=this.domAtPos(A.head+A.assoc,A.assoc);t.collapse(g.node,g.offset),t.modify("move",A.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let C=e.observer.selectionRange;e.docView.posFromDOM(C.anchorNode,C.anchorOffset)!=A.from&&t.collapse(n,o)}posFromDOM(e,A){let t=this.tile.nearest(e);if(!t)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=t.posAtStart;if(t.isComposite()){let o;if(e==t.dom)o=t.dom.childNodes[A];else{let a=cC(e)==0?0:A==0?-1:1;for(;;){let r=e.parentNode;if(r==t.dom)break;a==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?a=-1:a=1),e=r}a<0?o=e:o=e.nextSibling}if(o==t.dom.firstChild)return n;for(;o&&!_a.get(o);)o=o.nextSibling;if(!o)return n+t.length;for(let a=0,r=n;;a++){let s=t.children[a];if(s.dom==o)return r;r+=s.length+s.breakAfter}}else return t.isText()?e==t.dom?n+A:n+(A?t.length:0):n}domAtPos(e,A){let{tile:t,offset:n}=this.tile.resolveBlock(e,A);return t.isWidget()?t.domPosFor(e,A):t.domIn(n,A)}inlineDOMNearPos(e,A){let t,n=-1,o=!1,a,r=-1,s=!1;return this.tile.blockTiles((l,g)=>{if(l.isWidget()){if(l.flags&32&&g>=e)return!0;l.flags&16&&(o=!0)}else{let C=g+l.length;if(g<=e&&(t=l,n=e-g,o=C<e),C>=e&&!a&&(a=l,r=e-g,s=g>e),g>e&&a)return!0}}),!t&&!a?this.domAtPos(e,A):(o&&a?t=null:s&&t&&(a=null),t&&A<0||!a?t.domIn(n,A):a.domIn(r,A))}coordsAt(e,A){let{tile:t,offset:n}=this.tile.resolveBlock(e,A);return t.isWidget()?t.widget instanceof i4?null:t.coordsInWidget(n,A,!0):t.coordsIn(n,A)}lineAt(e,A){let{tile:t}=this.tile.resolveBlock(e,A);return t.isLine()?t:null}coordsForChar(e){let{tile:A,offset:t}=this.tile.resolveBlock(e,1);if(!A.isLine())return null;function n(o,a){if(o.isComposite())for(let r of o.children){if(r.length>=a){let s=n(r,a);if(s)return s}if(a-=r.length,a<0)break}else if(o.isText()&&a<o.length){let r=tr(o.text,a);if(r==a)return null;let s=c4(o.dom,a,r).getClientRects();for(let l=0;l<s.length;l++){let g=s[l];if(l==s.length-1||g.top<g.bottom&&g.left<g.right)return g}}return null}return n(A,t)}measureVisibleLineHeights(e){let A=[],{from:t,to:n}=e,o=this.view.contentDOM.clientWidth,a=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,s=this.view.textDirection==Lo.LTR,l=0,g=(C,d,B)=>{for(let u=0;u<C.children.length&&!(d>n);u++){let E=C.children[u],f=d+E.length,m=E.dom.getBoundingClientRect(),{height:v}=m;if(B&&!u&&(l+=m.top-B.top),E instanceof gC)f>t&&g(E,d,m);else if(d>=t&&(l>0&&A.push(-l),A.push(v+l),l=0,a)){let S=E.dom.lastChild,k=S?V6(S):[];if(k.length){let M=k[k.length-1],x=s?M.right-m.left:m.right-M.left;x>r&&(r=x,this.minWidth=o,this.minWidthFrom=d,this.minWidthTo=f)}}B&&u==C.children.length-1&&(l+=B.bottom-m.bottom),d=f+E.breakAfter}};return g(this.tile,0,null),A}textDirectionAt(e){let{tile:A}=this.tile.resolveBlock(e,1);return getComputedStyle(A.dom).direction=="rtl"?Lo.RTL:Lo.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let r=0,s;for(let l of a.children){if(!l.isText()||/[^ -~]/.test(l.text))return;let g=V6(l.dom);if(g.length!=1)return;r+=g[0].width,s=g[0].height}if(r)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:r/a.length,textHeight:s}}});if(e)return e;let A=document.createElement("div"),t,n,o;return A.className="cm-line",A.style.width="99999px",A.style.position="absolute",A.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(A);let a=V6(A.firstChild)[0];t=A.getBoundingClientRect().height,n=a&&a.width?a.width/27:7,o=a&&a.height?a.height:t,A.remove()}),{lineHeight:t,charWidth:n,textHeight:o}}computeBlockGapDeco(){let e=[],A=this.view.viewState;for(let t=0,n=0;;n++){let o=n==A.viewports.length?null:A.viewports[n],a=o?o.from-1:this.view.state.doc.length;if(a>t){let r=(A.lineBlockAt(a).bottom-A.lineBlockAt(t).top)/this.view.scaleY;e.push(Lt.replace({widget:new i4(r),block:!0,inclusive:!0,isBlockGap:!0}).range(t,a))}if(!o)break;t=o.to+1}return Lt.set(e)}updateDeco(){let e=1,A=this.view.state.facet(Q8).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),t=!1,n=this.view.state.facet(uS).map((o,a)=>{let r=typeof o=="function";return r&&(t=!0),r?o(this.view):o});for(n.length&&(this.dynamicDecorationMap[e++]=t,A.push(uo.join(n))),this.decorations=[this.editContextFormatting,...A,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(tH).map(o=>typeof o=="function"?o(this.view):o)}scrollIntoView(e){var A;if(e.isSnapshot){let g=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=g.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let g of this.view.state.facet(AH))try{if(g(this.view,e.range,e))return!0}catch(C){Gr(this.view.state,C,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,(A=t.assoc)!==null&&A!==void 0?A:t.empty?0:t.head>t.anchor?-1:1),o;if(!n)return;!t.empty&&(o=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,o.left),top:Math.min(n.top,o.top),right:Math.max(n.right,o.right),bottom:Math.max(n.bottom,o.bottom)});let a=pS(this.view),r={left:n.left-a.left,top:n.top-a.top,right:n.right+a.right,bottom:n.bottom+a.bottom},{offsetWidth:s,offsetHeight:l}=this.view.scrollDOM;if(WgA(this.view.scrollDOM,r,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==Lo.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let g=this.view.docView.lineAt(t.head,1);g&&g.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let A=t=>t.isWidget()||t.children.some(A);return A(this.tile.resolveBlock(e,1).tile)}destroy(){L9(this.tile)}};function L9(i,e){let A=e?.get(i);if(A!=1){A==null&&i.destroy();for(let t of i.children)L9(t,e)}}function BcA(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function aH(i,e){let A=i.observer.selectionRange;if(!A.focusNode)return null;let t=TY(A.focusNode,A.focusOffset),n=OY(A.focusNode,A.focusOffset),o=t||n;if(n&&t&&n.node!=t.node){let r=_a.get(n.node);if(!r||r.isText()&&r.text!=n.node.nodeValue)o=n;else if(i.docView.lastCompositionAfterCursor){let s=_a.get(t.node);!s||s.isText()&&s.text!=t.node.nodeValue||(o=n)}}if(i.docView.lastCompositionAfterCursor=o!=t,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function hcA(i,e,A){let t=aH(i,A);if(!t)return null;let{node:n,from:o,to:a}=t,r=n.nodeValue;if(/[\n\r]/.test(r)||i.state.doc.sliceString(t.from,t.to)!=r)return null;let s=e.invertedDesc;return{range:new rc(s.mapPos(o),s.mapPos(a),o,a),text:n}}function EcA(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}var QcA=class{constructor(){this.changes=[]}compareRange(e,A){th(e,A,this.changes)}comparePoint(e,A){th(e,A,this.changes)}boundChange(e){th(e,e,this.changes)}};function ucA(i,e,A){let t=new QcA;return uo.compare(i,e,A,t),t.changes}var G9=class{constructor(){this.changes=[]}compareRange(e,A){th(e,A,this.changes)}comparePoint(){}boundChange(e){th(e,e,this.changes)}};function pcA(i,e,A){let t=new G9;return uo.compare(i,e,A,t),t.changes}function fcA(i,e){for(let A=i;A&&A!=e;A=A.assignedSlot||A.parentNode)if(A.nodeType==1&&A.contentEditable=="false")return!0;return!1}function mcA(i,e){let A=!1;return e&&i.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(A=!0)}),A}var i4=class extends gl{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function wcA(i,e,A=1){let t=i.charCategorizer(e),n=i.doc.lineAt(e),o=e-n.from;if(n.length==0)return Be.cursor(e);o==0?A=1:o==n.length&&(A=-1);let a=o,r=o;A<0?a=tr(n.text,o,!1):r=tr(n.text,o);let s=t(n.text.slice(a,r));for(;a>0;){let l=tr(n.text,a,!1);if(t(n.text.slice(l,a))!=s)break;a=l}for(;r<n.length;){let l=tr(n.text,r);if(t(n.text.slice(r,l))!=s)break;r=l}return Be.range(a+n.from,r+n.from)}function ycA(i,e,A,t,n){let o=Math.round((t-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&A.height>i.defaultLineHeight*1.5){let r=i.viewState.heightOracle.textHeight,s=Math.floor((n-A.top-(i.defaultLineHeight-r)*.5)/r);o+=s*i.viewState.heightOracle.lineLength}let a=i.state.sliceDoc(A.from,A.to);return A.from+G6(a,o,i.state.tabSize)}function K9(i,e,A){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){let n;for(let o of t.type){if(o.from>e)break;if(!(o.to<e)){if(o.from<e&&o.to>e)return o;(!n||o.type==As.Text&&(n.type!=o.type||(A<0?o.from<e:o.to>e)))&&(n=o)}}return n||t}return t}function DcA(i,e,A,t){let n=K9(i,e.head,e.assoc||-1),o=!t||n.type!=As.Text||!(i.lineWrapping||n.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(o){let a=i.dom.getBoundingClientRect(),r=i.textDirectionAt(n.from),s=i.posAtCoords({x:A==(r==Lo.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(s!=null)return Be.cursor(s,A?-1:1)}return Be.cursor(A?n.to:n.from,A?-1:1)}function oY(i,e,A,t){let n=i.state.doc.lineAt(e.head),o=i.bidiSpans(n),a=i.textDirectionAt(n.from);for(let r=e,s=null;;){let l=acA(n,o,a,r,A),g=PY;if(!l){if(n.number==(A?i.state.doc.lines:1))return r;g=` |
| 253 | `&&i.lineWrapping&&(t&&(t=Be.single(t.main.anchor-1,t.main.head-1)),A={from:o.from,to:o.to,insert:On.of([" "])}),A)return fS(i,A,t,a);if(t&&!r8(t,o)){let r=!1,s="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(r=!0),s=i.inputState.lastSelectionOrigin,s=="select.pointer"&&(t=rH(n.facet(C4).map(l=>l(i)),t))),i.dispatch({selection:t,scrollIntoView:r,userEvent:s}),!0}else return!1}function fS(i,e,A,t=-1){if(Ct.ios&&i.inputState.flushIOSKey(e))return!0;let n=i.state.selection.main;if(Ct.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&i.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ih(i.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||t==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&ih(i.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ih(i.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let a,r=()=>a||(a=kcA(i,e,A));return i.state.facet(ZY).some(s=>s(i,e.from,e.to,o,r))||i.dispatch(r()),!0}function kcA(i,e,A){let t,n=i.state,o=n.selection.main,a=-1;if(e.from==e.to&&e.from<o.from||e.from>o.to){let s=e.from<o.from?-1:1,l=s<0?o.from:o.to,g=n4(n.facet(C4).map(C=>C(i)),l,s);e.from==g&&(a=g)}if(a>-1)t={changes:e,selection:Be.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!A||A.main.empty&&A.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let s=o.from<e.from?n.sliceDoc(o.from,e.from):"",l=o.to>e.to?n.sliceDoc(e.to,o.to):"";t=n.replaceSelection(i.state.toText(s+e.insert.sliceString(0,void 0,i.state.lineBreak)+l))}else{let s=n.changes(e),l=A&&A.main.to<=s.newLength?A.main:void 0;if(n.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let g=i.state.sliceDoc(e.from,e.to),C,d=A&&aH(i,A.main.head);if(d){let u=e.insert.length-(e.to-e.from);C={from:d.from,to:d.to-u}}else C=i.state.doc.lineAt(o.head);let B=o.to-e.to;t=n.changeByRange(u=>{if(u.from==o.from&&u.to==o.to)return{changes:s,range:l||u.map(s)};let E=u.to-B,f=E-g.length;if(i.state.sliceDoc(f,E)!=g||E>=C.from&&f<=C.to)return{range:u};let m=n.changes({from:f,to:E,insert:e.insert}),v=u.to-o.to;return{changes:m,range:l?Be.range(Math.max(0,l.anchor+v),Math.max(0,l.head+v)):u.map(m)}})}else t={changes:s,selection:l&&n.selection.replaceRange(l)}}let r="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,r+=".compose",i.inputState.compositionFirstChange&&(r+=".start",i.inputState.compositionFirstChange=!1)),n.update(t,{userEvent:r,scrollIntoView:!0})}function gH(i,e,A,t){let n=Math.min(i.length,e.length),o=0;for(;o<n&&i.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==n&&i.length==e.length)return null;let a=i.length,r=e.length;for(;a>0&&r>0&&i.charCodeAt(a-1)==e.charCodeAt(r-1);)a--,r--;if(t=="end"){let s=Math.max(0,o-Math.min(a,r));A-=a+s-o}if(a<o&&i.length<e.length){let s=A<=o&&A>=a?o-A:0;o-=s,r=o+(r-a),a=o}else if(r<o){let s=A<=o&&A>=r?o-A:0;o-=s,a=o+(a-r),r=o}return{from:o,toA:a,toB:r}}function _cA(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:A,anchorOffset:t,focusNode:n,focusOffset:o}=i.observer.selectionRange;return A&&(e.push(new a8(A,t)),(n!=A||o!=t)&&e.push(new a8(n,o))),e}function xcA(i,e){if(i.length==0)return null;let A=i[0].pos,t=i.length==2?i[1].pos:A;return A>-1&&t>-1?Be.single(A+e,t+e):null}function r8(i,e){return e.head==i.main.head&&e.anchor==i.main.anchor}var Y9=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.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=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.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ct.safari&&e.contentDOM.addEventListener("input",()=>null),Ct.gecko&&PcA(e.contentDOM.ownerDocument)}handleEvent(e){!UcA(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,A){let t=this.handlers[e];if(t){for(let n of t.observers)n(this.view,A);for(let n of t.handlers){if(A.defaultPrevented)break;if(n(this.view,A)){A.preventDefault();break}}}}ensureHandlers(e){let A=RcA(e),t=this.handlers,n=this.view.contentDOM;for(let o in A)if(o!="scroll"){let a=!A[o].handlers.length,r=t[o];r&&a!=!r.handlers.length&&(n.removeEventListener(o,this.handleEvent),r=null),r||n.addEventListener(o,this.handleEvent,{passive:a})}for(let o in t)o!="scroll"&&!A[o]&&n.removeEventListener(o,this.handleEvent);this.handlers=A}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&CH.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ct.android&&Ct.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let A;return Ct.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((A=cH.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||NcA.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=A||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let A=this.pendingIOSKey;return!A||A.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ih(this.view.contentDOM,A.key,A.keyCode,A instanceof KeyboardEvent?A:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ct.safari&&!Ct.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.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 aY(i,e){return(A,t)=>{try{return e.call(i,t,A)}catch(n){Gr(A.state,n)}}}function RcA(i){let e=Object.create(null);function A(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let t of i){let n=t.spec,o=n&&n.plugin.domEventHandlers,a=n&&n.plugin.domEventObservers;if(o)for(let r in o){let s=o[r];s&&A(r).handlers.push(aY(t.value,s))}if(a)for(let r in a){let s=a[r];s&&A(r).observers.push(aY(t.value,s))}}for(let t in sc)A(t).handlers.push(sc[t]);for(let t in cl)A(t).observers.push(cl[t]);return e}var cH=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],NcA="dthko",CH=[16,17,18,20,91,92,224,225],T6=6;function O6(i){return Math.max(0,i)*.7+8}function FcA(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var H9=class{constructor(e,A,t,n){this.view=e,this.startEvent=A,this.style=t,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=A,this.scrollParents=GY(e.contentDOM),this.atoms=e.state.facet(C4).map(a=>a(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=A.shiftKey,this.multiple=e.state.facet(ir.allowMultipleSelections)&&LcA(e,A),this.dragging=KcA(e,A)&&BH(A)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&FcA(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let A=0,t=0,n=0,o=0,a=this.view.win.innerWidth,r=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:r}=this.scrollParents.y.getBoundingClientRect());let s=pS(this.view);e.clientX-s.left<=n+T6?A=-O6(n-e.clientX):e.clientX+s.right>=a-T6&&(A=O6(e.clientX-a)),e.clientY-s.top<=o+T6?t=-O6(o-e.clientY):e.clientY+s.bottom>=r-T6&&(t=O6(e.clientY-r)),this.setScrollSpeed(A,t)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,A){this.scrollSpeed={x:e,y:A},e||A?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:A}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),A&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=A,A=0),(e||A)&&this.view.win.scrollBy(e,A),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:A}=this,t=rH(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!t.eq(A.state.selection,this.dragging===!1))&&this.view.dispatch({selection:t,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(A=>A.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function LcA(i,e){let A=i.state.facet(jY);return A.length?A[0](e):Ct.mac?e.metaKey:e.ctrlKey}function GcA(i,e){let A=i.state.facet(VY);return A.length?A[0](e):Ct.mac?!e.altKey:!e.ctrlKey}function KcA(i,e){let{main:A}=i.state.selection;if(A.empty)return!1;let t=g4(i.root);if(!t||t.rangeCount==0)return!0;let n=t.getRangeAt(0).getClientRects();for(let o=0;o<n.length;o++){let a=n[o];if(a.left<=e.clientX&&a.right>=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function UcA(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let A=e.target,t;A!=i.contentDOM;A=A.parentNode)if(!A||A.nodeType==11||(t=_a.get(A))&&t.isWidget()&&!t.isHidden&&t.widget.ignoreEvent(e))return!1;return!0}var sc=Object.create(null),cl=Object.create(null),dH=Ct.ie&&Ct.ie_version<15||Ct.ios&&Ct.webkit_version<604;function TcA(i){let e=i.dom.parentNode;if(!e)return;let A=e.appendChild(document.createElement("textarea"));A.style.cssText="position: fixed; left: -10000px; top: 10px",A.focus(),setTimeout(()=>{i.focus(),A.remove(),IH(i,A.value)},50)}function u8(i,e,A){for(let t of i.facet(e))A=t(A,i);return A}function IH(i,e){e=u8(i.state,ES,e);let{state:A}=i,t,n=1,o=A.toText(e),a=o.lines==A.selection.ranges.length;if(z9!=null&&A.selection.ranges.every(s=>s.empty)&&z9==o.toString()){let s=-1;t=A.changeByRange(l=>{let g=A.doc.lineAt(l.from);if(g.from==s)return{range:l};s=g.from;let C=A.toText((a?o.line(n++).text:e)+A.lineBreak);return{changes:{from:g.from,insert:C},range:Be.cursor(l.from+C.length)}})}else a?t=A.changeByRange(s=>{let l=o.line(n++);return{changes:{from:s.from,to:s.to,insert:l.text},range:Be.cursor(s.from+l.length)}}):t=A.replaceSelection(o);i.dispatch(t,{userEvent:"input.paste",scrollIntoView:!0})}cl.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};cl.wheel=cl.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};sc.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);cl.touchstart=(i,e)=>{let A=i.inputState,t=e.targetTouches[0];A.lastTouchTime=Date.now(),t&&(A.lastTouchX=t.clientX,A.lastTouchY=t.clientY),A.setSelectionOrigin("select.pointer")};cl.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};sc.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let A=null;for(let t of i.state.facet(qY))if(A=t(i,e),A)break;if(!A&&e.button==0&&(A=JcA(i,e)),A){let t=!i.hasFocus;i.inputState.startMouseSelection(new H9(i,e,A,t)),t&&i.observer.ignore(()=>{KY(i.contentDOM);let o=i.root.activeElement;o&&!o.contains(i.contentDOM)&&o.blur()});let n=i.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function rY(i,e,A,t){if(t==1)return Be.cursor(e,A);if(t==2)return wcA(i.state,e,A);{let n=i.docView.lineAt(e,A),o=i.state.doc.lineAt(n?n.posAtEnd:e),a=n?n.posAtStart:o.from,r=n?n.posAtEnd:o.to;return r<i.state.doc.length&&r==o.to&&r++,Be.range(a,r)}}var OcA=Ct.ie&&Ct.ie_version<=11,sY=null,lY=0,gY=0;function BH(i){if(!OcA)return i.detail;let e=sY,A=gY;return sY=i,gY=Date.now(),lY=!e||A>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(lY+1)%3:1}function JcA(i,e){let A=i.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),t=BH(e),n=i.state.selection;return{update(o){o.docChanged&&(A.pos=o.changes.mapPos(A.pos),n=n.map(o.changes))},get(o,a,r){let s=i.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),l,g=rY(i,s.pos,s.assoc,t);if(A.pos!=s.pos&&!a){let C=rY(i,A.pos,A.assoc,t),d=Math.min(C.from,g.from),B=Math.max(C.to,g.to);g=d<g.from?Be.range(d,B,g.assoc):Be.range(B,d,g.assoc)}return a?n.replaceRange(n.main.extend(g.from,g.to,g.assoc)):r&&t==1&&n.ranges.length>1&&(l=YcA(n,s.pos))?l:r?n.addRange(g):Be.create([g])}}}function YcA(i,e){for(let A=0;A<i.ranges.length;A++){let{from:t,to:n}=i.ranges[A];if(t<=e&&n>=e)return Be.create(i.ranges.slice(0,A).concat(i.ranges.slice(A+1)),i.mainIndex==A?0:i.mainIndex-(i.mainIndex>A?1:0))}return null}sc.dragstart=(i,e)=>{let{selection:{main:A}}=i.state;if(e.target.draggable){let n=i.docView.tile.nearest(e.target);if(n&&n.isWidget()){let o=n.posAtStart,a=o+n.length;(o>=A.to||a<=A.from)&&(A=Be.range(o,a))}}let{inputState:t}=i;return t.mouseSelection&&(t.mouseSelection.dragging=!0),t.draggedContent=A,e.dataTransfer&&(e.dataTransfer.setData("Text",u8(i.state,QS,i.state.sliceDoc(A.from,A.to))),e.dataTransfer.effectAllowed="copyMove"),!1};sc.dragend=i=>(i.inputState.draggedContent=null,!1);function cY(i,e,A,t){if(A=u8(i.state,ES,A),!A)return;let n=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=i.inputState,a=t&&o&&GcA(i,e)?{from:o.from,to:o.to}:null,r={from:n,insert:A},s=i.state.changes(a?[a,r]:r);i.focus(),i.dispatch({changes:s,selection:{anchor:s.mapPos(n,-1),head:s.mapPos(n,1)},userEvent:a?"move.drop":"input.drop"}),i.inputState.draggedContent=null}sc.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let A=e.dataTransfer.files;if(A&&A.length){let t=Array(A.length),n=0,o=()=>{++n==A.length&&cY(i,e,t.filter(a=>a!=null).join(i.state.lineBreak),!1)};for(let a=0;a<A.length;a++){let r=new FileReader;r.onerror=o,r.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(r.result)||(t[a]=r.result),o()},r.readAsText(A[a])}return!0}else{let t=e.dataTransfer.getData("Text");if(t)return cY(i,e,t,!0),!0}return!1};sc.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let A=dH?null:e.clipboardData;return A?(IH(i,A.getData("text/plain")||A.getData("text/uri-list")),!0):(TcA(i),!1)};function HcA(i,e){let A=i.dom.parentNode;if(!A)return;let t=A.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.value=e,t.focus(),t.selectionEnd=e.length,t.selectionStart=0,setTimeout(()=>{t.remove(),i.focus()},50)}function zcA(i){let e=[],A=[],t=!1;for(let n of i.selection.ranges)n.empty||(e.push(i.sliceDoc(n.from,n.to)),A.push(n));if(!e.length){let n=-1;for(let{from:o}of i.selection.ranges){let a=i.doc.lineAt(o);a.number>n&&(e.push(a.text),A.push({from:a.from,to:Math.min(i.doc.length,a.to+1)})),n=a.number}t=!0}return{text:u8(i,QS,e.join(i.lineBreak)),ranges:A,linewise:t}}var z9=null;sc.copy=sc.cut=(i,e)=>{if(!$u(i.contentDOM,i.observer.selectionRange))return!1;let{text:A,ranges:t,linewise:n}=zcA(i.state);if(!A&&!n)return!1;z9=n?A:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:t,scrollIntoView:!0,userEvent:"delete.cut"});let o=dH?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",A),!0):(HcA(i,A),!1)};var hH=sl.define();function EH(i,e){let A=[];for(let t of i.facet(XY)){let n=t(i,e);n&&A.push(n)}return A.length?i.update({effects:A,annotations:hH.of(!0)}):null}function QH(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let A=EH(i.state,e);A?i.dispatch(A):i.update([])}},10)}cl.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),QH(i)};cl.blur=i=>{i.observer.clearSelectionRange(),QH(i)};cl.compositionstart=cl.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};cl.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,Ct.chrome&&Ct.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};cl.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};sc.beforeinput=(i,e)=>{var A,t;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let o=(A=e.dataTransfer)===null||A===void 0?void 0:A.getData("text/plain"),a=e.getTargetRanges();if(o&&a.length){let r=a[0],s=i.posAtDOM(r.startContainer,r.startOffset),l=i.posAtDOM(r.endContainer,r.endOffset);return fS(i,{from:s,to:l,insert:i.state.toText(o)},null),!0}}let n;if(Ct.chrome&&Ct.android&&(n=cH.find(o=>o.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let o=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>o+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return Ct.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),Ct.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>cl.compositionend(i,e),20),!1};var CY=new Set;function PcA(i){CY.has(i)||(CY.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var dY=["pre-wrap","normal","pre-line","break-spaces"],sh=!1;function IY(){sh=!1}var P9=class{constructor(e){this.lineWrapping=e,this.doc=On.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,A){let t=this.doc.lineAt(A).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(t+=Math.max(0,Math.ceil((A-e-t*this.lineLength*.5)/this.lineLength))),this.lineHeight*t}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return dY.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let A=!1;for(let t=0;t<e.length;t++){let n=e[t];n<0?t++:this.heightSamples[Math.floor(n*10)]||(A=!0,this.heightSamples[Math.floor(n*10)]=!0)}return A}refresh(e,A,t,n,o,a){let r=dY.indexOf(e)>-1,s=Math.abs(A-this.lineHeight)>.3||this.lineWrapping!=r||Math.abs(t-this.charWidth)>.1;if(this.lineWrapping=r,this.lineHeight=A,this.charWidth=t,this.textHeight=n,this.lineLength=o,s){this.heightSamples={};for(let l=0;l<a.length;l++){let g=a[l];g<0?l++:this.heightSamples[Math.floor(g*10)]=!0}}return s}},j9=class{constructor(e,A){this.from=e,this.heights=A,this.index=0}get more(){return this.index<this.heights.length}},ac=class i{constructor(e,A,t,n,o){this.from=e,this.length=A,this.top=t,this.height=n,this._content=o}get type(){return typeof this._content=="number"?As.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof wd?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let A=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new i(this.from,this.length+e.length,this.top,this.height+e.height,A)}},Qa=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(Qa||(Qa={})),q6=.001,Nl=class i{constructor(e,A,t=2){this.length=e,this.height=A,this.flags=t}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>q6&&(sh=!0),this.height=e)}replace(e,A,t){return i.of(t)}decomposeLeft(e,A){A.push(this)}decomposeRight(e,A){A.push(this)}applyChanges(e,A,t,n){let o=this,a=t.doc;for(let r=n.length-1;r>=0;r--){let{fromA:s,toA:l,fromB:g,toB:C}=n[r],d=o.lineAt(s,Qa.ByPosNoHeight,t.setDoc(A),0,0),B=d.to>=l?d:o.lineAt(l,Qa.ByPosNoHeight,t,0,0);for(C+=B.to-l,l=B.to;r>0&&d.from<=n[r-1].toA;)s=n[r-1].fromA,g=n[r-1].fromB,r--,s<d.from&&(d=o.lineAt(s,Qa.ByPosNoHeight,t,0,0));g+=d.from-s,s=d.from;let u=q9.build(t.setDoc(a),e,g,C);o=s8(o,o.replace(s,l,u))}return o.updateHeight(t,0)}static empty(){return new dg(0,0,0)}static of(e){if(e.length==1)return e[0];let A=0,t=e.length,n=0,o=0;for(;;)if(A==t)if(n>o*2){let r=e[A-1];r.break?e.splice(--A,1,r.left,null,r.right):e.splice(--A,1,r.left,r.right),t+=1+r.break,n-=r.size}else if(o>n*2){let r=e[t];r.break?e.splice(t,1,r.left,null,r.right):e.splice(t,1,r.left,r.right),t+=2+r.break,o-=r.size}else break;else if(n<o){let r=e[A++];r&&(n+=r.size)}else{let r=e[--t];r&&(o+=r.size)}let a=0;return e[A-1]==null?(a=1,A--):e[A]==null&&(a=1,t++),new V9(i.of(e.slice(0,A)),a,i.of(e.slice(t)))}};function s8(i,e){return i==e?i:(i.constructor!=e.constructor&&(sh=!0),e)}Nl.prototype.size=1;var jcA=Lt.replace({}),l8=class extends Nl{constructor(e,A,t){super(e,A),this.deco=t,this.spaceAbove=0}mainBlock(e,A){return new ac(A,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,A,t,n){return this.spaceAbove&&e<t+this.spaceAbove?new ac(n,0,t,this.spaceAbove,jcA):this.mainBlock(t,n)}lineAt(e,A,t,n,o){let a=this.mainBlock(n,o);return this.spaceAbove?this.blockAt(0,t,n,o).join(a):a}forEachLine(e,A,t,n,o,a){e<=o+this.length&&A>=o&&a(this.lineAt(0,Qa.ByPos,t,n,o))}setMeasuredHeight(e){let A=e.heights[e.index++];A<0?(this.spaceAbove=-A,A=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(A)}updateHeight(e,A=0,t=!1,n){return n&&n.from<=A&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}},dg=class i extends l8{constructor(e,A,t){super(e,A,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=t}mainBlock(e,A){return new ac(A,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,A,t){let n=t[0];return t.length==1&&(n instanceof i||n instanceof M2&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof M2?n=new i(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):Nl.of(t)}updateHeight(e,A=0,t=!1,n){return n&&n.from<=A&&n.more?this.setMeasuredHeight(n):(t||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},M2=class i extends Nl{constructor(e){super(e,0)}heightMetrics(e,A){let t=e.doc.lineAt(A).number,n=e.doc.lineAt(A+this.length).number,o=n-t+1,a,r=0;if(e.lineWrapping){let s=Math.min(this.height,e.lineHeight*o);a=s/o,this.length>o+1&&(r=(this.height-s)/(this.length-o-1))}else a=this.height/o;return{firstLine:t,lastLine:n,perLine:a,perChar:r}}blockAt(e,A,t,n){let{firstLine:o,lastLine:a,perLine:r,perChar:s}=this.heightMetrics(A,n);if(A.lineWrapping){let l=n+(e<A.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-t)/this.height))*this.length)),g=A.doc.lineAt(l),C=r+g.length*s,d=Math.max(t,e-C/2);return new ac(g.from,g.length,d,C,0)}else{let l=Math.max(0,Math.min(a-o,Math.floor((e-t)/r))),{from:g,length:C}=A.doc.line(o+l);return new ac(g,C,t+r*l,r,0)}}lineAt(e,A,t,n,o){if(A==Qa.ByHeight)return this.blockAt(e,t,n,o);if(A==Qa.ByPosNoHeight){let{from:B,to:u}=t.doc.lineAt(e);return new ac(B,u-B,0,0,0)}let{firstLine:a,perLine:r,perChar:s}=this.heightMetrics(t,o),l=t.doc.lineAt(e),g=r+l.length*s,C=l.number-a,d=n+r*C+s*(l.from-o-C);return new ac(l.from,l.length,Math.max(n,Math.min(d,n+this.height-g)),g,0)}forEachLine(e,A,t,n,o,a){e=Math.max(e,o),A=Math.min(A,o+this.length);let{firstLine:r,perLine:s,perChar:l}=this.heightMetrics(t,o);for(let g=e,C=n;g<=A;){let d=t.doc.lineAt(g);if(g==e){let u=d.number-r;C+=s*u+l*(e-o-u)}let B=s+l*d.length;a(new ac(d.from,d.length,C,B,0)),C+=B,g=d.to+1}}replace(e,A,t){let n=this.length-A;if(n>0){let o=t[t.length-1];o instanceof i?t[t.length-1]=new i(o.length+n):t.push(null,new i(n-1))}if(e>0){let o=t[0];o instanceof i?t[0]=new i(e+o.length):t.unshift(new i(e-1),null)}return Nl.of(t)}decomposeLeft(e,A){A.push(new i(e-1),null)}decomposeRight(e,A){A.push(null,new i(this.length-e-1))}updateHeight(e,A=0,t=!1,n){let o=A+this.length;if(n&&n.from<=A+this.length&&n.more){let a=[],r=Math.max(A,n.from),s=-1;for(n.from>A&&a.push(new i(n.from-A-1).updateHeight(e,A));r<=o&&n.more;){let g=e.doc.lineAt(r).length;a.length&&a.push(null);let C=n.heights[n.index++],d=0;C<0&&(d=-C,C=n.heights[n.index++]),s==-1?s=C:Math.abs(C-s)>=q6&&(s=-2);let B=new dg(g,C,d);B.outdated=!1,a.push(B),r+=g+1}r<=o&&a.push(null,new i(o-r).updateHeight(e,r));let l=Nl.of(a);return(s<0||Math.abs(l.height-this.height)>=q6||Math.abs(s-this.heightMetrics(e,A).perLine)>=q6)&&(sh=!0),s8(this,l)}else(t||this.outdated)&&(this.setHeight(e.heightForGap(A,A+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},V9=class extends Nl{constructor(e,A,t){super(e.length+A+t.length,e.height+t.height,A|(e.outdated||t.outdated?2:0)),this.left=e,this.right=t,this.size=e.size+t.size}get break(){return this.flags&1}blockAt(e,A,t,n){let o=t+this.left.height;return e<o?this.left.blockAt(e,A,t,n):this.right.blockAt(e,A,o,n+this.left.length+this.break)}lineAt(e,A,t,n,o){let a=n+this.left.height,r=o+this.left.length+this.break,s=A==Qa.ByHeight?e<a:e<r,l=s?this.left.lineAt(e,A,t,n,o):this.right.lineAt(e,A,t,a,r);if(this.break||(s?l.to<r:l.from>r))return l;let g=A==Qa.ByPosNoHeight?Qa.ByPosNoHeight:Qa.ByPos;return s?l.join(this.right.lineAt(r,g,t,a,r)):this.left.lineAt(r,g,t,n,o).join(l)}forEachLine(e,A,t,n,o,a){let r=n+this.left.height,s=o+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,A,t,n,o,a),A>=s&&this.right.forEachLine(e,A,t,r,s,a);else{let l=this.lineAt(s,Qa.ByPos,t,n,o);e<l.from&&this.left.forEachLine(e,l.from-1,t,n,o,a),l.to>=e&&l.from<=A&&a(l),A>l.to&&this.right.forEachLine(l.to+1,A,t,r,s,a)}}replace(e,A,t){let n=this.left.length+this.break;if(A<n)return this.balanced(this.left.replace(e,A,t),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,A-n,t));let o=[];e>0&&this.decomposeLeft(e,o);let a=o.length;for(let r of t)o.push(r);if(e>0&&BY(o,a-1),A<this.length){let r=o.length;this.decomposeRight(A,o),BY(o,r)}return Nl.of(o)}decomposeLeft(e,A){let t=this.left.length;if(e<=t)return this.left.decomposeLeft(e,A);A.push(this.left),this.break&&(t++,e>=t&&A.push(null)),e>t&&this.right.decomposeLeft(e-t,A)}decomposeRight(e,A){let t=this.left.length,n=t+this.break;if(e>=n)return this.right.decomposeRight(e-n,A);e<t&&this.left.decomposeRight(e,A),this.break&&e<n&&A.push(null),A.push(this.right)}balanced(e,A){return e.size>2*A.size||A.size>2*e.size?Nl.of(this.break?[e,null,A]:[e,A]):(this.left=s8(this.left,e),this.right=s8(this.right,A),this.setHeight(e.height+A.height),this.outdated=e.outdated||A.outdated,this.size=e.size+A.size,this.length=e.length+this.break+A.length,this)}updateHeight(e,A=0,t=!1,n){let{left:o,right:a}=this,r=A+o.length+this.break,s=null;return n&&n.from<=A+o.length&&n.more?s=o=o.updateHeight(e,A,t,n):o.updateHeight(e,A,t),n&&n.from<=r+a.length&&n.more?s=a=a.updateHeight(e,r,t,n):a.updateHeight(e,r,t),s?this.balanced(o,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function BY(i,e){let A,t;i[e]==null&&(A=i[e-1])instanceof M2&&(t=i[e+1])instanceof M2&&i.splice(e-1,3,new M2(A.length+1+t.length))}var VcA=5,q9=class i{constructor(e,A){this.pos=e,this.oracle=A,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,A){if(this.lineStart>-1){let t=Math.min(A,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof dg?n.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new dg(t-this.pos,-1,0)),this.writtenTo=t,A>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=A}point(e,A,t){if(e<A||t.heightRelevant){let n=t.widget?t.widget.estimatedHeight:0,o=t.widget?t.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let a=A-e;t.block?this.addBlock(new l8(a,n,t)):(a||o||n>=VcA)&&this.addLineDeco(n,o,a)}else A>e&&this.span(e,A);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:A}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=A,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new dg(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,A){let t=new M2(A-e);return this.oracle.doc.lineAt(e).to==A&&(t.flags|=4),t}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof dg)return e;let A=new dg(0,-1,0);return this.nodes.push(A),A}addBlock(e){this.enterLine();let A=e.deco;A&&A.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,A&&A.endSide>0&&(this.covering=e)}addLineDeco(e,A,t){let n=this.ensureLine();n.length+=t,n.collapsed+=t,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=A,this.writtenTo=this.pos=this.pos+t}finish(e){let A=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(A instanceof dg)&&!this.isCovered?this.nodes.push(new dg(0,-1,0)):(this.writtenTo<this.pos||A==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let t=e;for(let n of this.nodes)n instanceof dg&&n.updateHeight(this.oracle,t),t+=n?n.length:1;return this.nodes}static build(e,A,t,n){let o=new i(t,e);return uo.spans(A,t,n,o,0),o.finish(t)}};function qcA(i,e,A){let t=new W9;return uo.compare(i,e,A,t,0),t.changes}var W9=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,A,t,n){(e<A||t&&t.heightRelevant||n&&n.heightRelevant)&&th(e,A,this.changes,5)}};function WcA(i,e){let A=i.getBoundingClientRect(),t=i.ownerDocument,n=t.defaultView||window,o=Math.max(0,A.left),a=Math.min(n.innerWidth,A.right),r=Math.max(0,A.top),s=Math.min(n.innerHeight,A.bottom);for(let l=i.parentNode;l&&l!=t.body;)if(l.nodeType==1){let g=l,C=window.getComputedStyle(g);if((g.scrollHeight>g.clientHeight||g.scrollWidth>g.clientWidth)&&C.overflow!="visible"){let d=g.getBoundingClientRect();o=Math.max(o,d.left),a=Math.min(a,d.right),r=Math.max(r,d.top),s=Math.min(l==i.parentNode?n.innerHeight:s,d.bottom)}l=C.position=="absolute"||C.position=="fixed"?g.offsetParent:g.parentNode}else if(l.nodeType==11)l=l.host;else break;return{left:o-A.left,right:Math.max(o,a)-A.left,top:r-(A.top+e),bottom:Math.max(r,s)-(A.top+e)}}function ZcA(i){let e=i.getBoundingClientRect(),A=i.ownerDocument.defaultView||window;return e.left<A.innerWidth&&e.right>0&&e.top<A.innerHeight&&e.bottom>0}function XcA(i,e){let A=i.getBoundingClientRect();return{left:0,right:A.right-A.left,top:e,bottom:A.bottom-(A.top+e)}}var o4=class{constructor(e,A,t,n){this.from=e,this.to=A,this.size=t,this.displaySize=n}static same(e,A){if(e.length!=A.length)return!1;for(let t=0;t<e.length;t++){let n=e[t],o=A[t];if(n.from!=o.from||n.to!=o.to||n.size!=o.size)return!1}return!0}draw(e,A){return Lt.replace({widget:new Z9(this.displaySize*(A?e.scaleY:e.scaleX),A)}).range(this.from,this.to)}},Z9=class extends gl{constructor(e,A){super(),this.size=e,this.vertical=A}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},g8=class{constructor(e,A){this.view=e,this.state=A,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=hY,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Lo.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=A.facet(S9).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new P9(t),this.stateDeco=EY(A),this.heightMap=Nl.empty().applyChanges(this.stateDeco,On.empty,this.heightOracle.setDoc(A.doc),[new rc(0,0,0,A.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Lt.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:A}=this.state.selection;for(let t=0;t<=1;t++){let n=t?A.head:A.anchor;if(!e.some(({from:o,to:a})=>n>=o&&n<=a)){let{from:o,to:a}=this.lineBlockAt(n);e.push(new $B(o,a))}}return this.viewports=e.sort((t,n)=>t.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?hY:new X9(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Zu(e,this.scaler))})}update(e,A=null){this.state=e.state;let t=this.stateDeco;this.stateDeco=EY(this.state);let n=e.changedRanges,o=rc.extendWithRanges(n,qcA(t,this.stateDeco,e?e.changes:Zr.empty(this.state.doc.length))),a=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);IY(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=a||sh)&&(e.flags|=2),r?(this.scrollAnchorPos=e.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(A&&(A.range.head<s.from||A.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,A));let l=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(l||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),A&&(this.scrollTarget=A),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet($Y)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,A=e.contentDOM,t=window.getComputedStyle(A),n=this.heightOracle,o=t.whiteSpace;this.defaultTextDirection=t.direction=="rtl"?Lo.RTL:Lo.LTR;let a=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",r=A.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let l=0,g=0;if(r.width&&r.height){let{scaleX:M,scaleY:x}=LY(A,r);(M>.005&&Math.abs(this.scaleX-M)>.005||x>.005&&Math.abs(this.scaleY-x)>.005)&&(this.scaleX=M,this.scaleY=x,l|=16,a=s=!0)}let C=(parseInt(t.paddingTop)||0)*this.scaleY,d=(parseInt(t.paddingBottom)||0)*this.scaleY;(this.paddingTop!=C||this.paddingBottom!=d)&&(this.paddingTop=C,this.paddingBottom=d,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let B=GY(this.view.contentDOM,!1).y;B!=this.scrollParent&&(this.scrollParent=B,this.scrollAnchorHeight=-1,this.scrollOffset=0);let u=this.getScrollOffset();this.scrollOffset!=u&&(this.scrollAnchorHeight=-1,this.scrollOffset=u),this.scrolledToBottom=UY(this.scrollParent||e.win);let E=(this.printing?XcA:WcA)(A,this.paddingTop),f=E.top-this.pixelViewport.top,m=E.bottom-this.pixelViewport.bottom;this.pixelViewport=E;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(s=!0)),!this.inView&&!this.scrollTarget&&!ZcA(e.dom))return 0;let S=r.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=r.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),s){let M=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(M)&&(a=!0),a||n.lineWrapping&&Math.abs(S-this.contentDOMWidth)>n.charWidth){let{lineHeight:x,charWidth:F,textHeight:z}=e.docView.measureTextSize();a=x>0&&n.refresh(o,x,F,z,Math.max(5,S/F),M),a&&(e.docView.minWidth=0,l|=16)}f>0&&m>0?g=Math.max(f,m):f<0&&m<0&&(g=Math.min(f,m)),IY();for(let x of this.viewports){let F=x.from==this.viewport.from?M:e.docView.measureVisibleLineHeights(x);this.heightMap=(a?Nl.empty().applyChanges(this.stateDeco,On.empty,this.heightOracle,[new rc(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,a,new j9(x.from,F))}sh&&(l|=2)}let k=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(l&2&&(l|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),l|=this.updateForViewport()),(l&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,A){let t=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,o=this.heightOracle,{visibleTop:a,visibleBottom:r}=this,s=new $B(n.lineAt(a-t*1e3,Qa.ByHeight,o,0,0).from,n.lineAt(r+(1-t)*1e3,Qa.ByHeight,o,0,0).to);if(A){let{head:l}=A.range;if(l<s.from||l>s.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),C=n.lineAt(l,Qa.ByPos,o,0,0),d;A.y=="center"?d=(C.top+C.bottom)/2-g/2:A.y=="start"||A.y=="nearest"&&l<s.from?d=C.top:d=C.bottom-g,s=new $B(n.lineAt(d-1e3/2,Qa.ByHeight,o,0,0).from,n.lineAt(d+g+1e3/2,Qa.ByHeight,o,0,0).to)}}return s}mapViewport(e,A){let t=A.mapPos(e.from,-1),n=A.mapPos(e.to,1);return new $B(this.heightMap.lineAt(t,Qa.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Qa.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:A},t=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,Qa.ByPos,this.heightOracle,0,0),{bottom:o}=this.heightMap.lineAt(A,Qa.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:r}=this;return(e==0||n<=a-Math.max(10,Math.min(-t,250)))&&(A==this.state.doc.length||o>=r+Math.max(10,Math.min(t,250)))&&n>a-2*1e3&&o<r+2*1e3}mapLineGaps(e,A){if(!e.length||A.empty)return e;let t=[];for(let n of e)A.touchesRange(n.from,n.to)||t.push(new o4(A.mapPos(n.from),A.mapPos(n.to),n.size,n.displaySize));return t}ensureLineGaps(e,A){let t=this.heightOracle.lineWrapping,n=t?1e4:2e3,o=n>>1,a=n<<1;if(this.defaultTextDirection!=Lo.LTR&&!t)return[];let r=[],s=(g,C,d,B)=>{if(C-g<o)return;let u=this.state.selection.main,E=[u.from];u.empty||E.push(u.to);for(let m of E)if(m>g&&m<C){s(g,m-10,d,B),s(m+10,C,d,B);return}let f=A0A(e,m=>m.from>=d.from&&m.to<=d.to&&Math.abs(m.from-g)<o&&Math.abs(m.to-C)<o&&!E.some(v=>m.from<v&&m.to>v));if(!f){if(C<d.to&&A&&t&&A.visibleRanges.some(S=>S.from<=C&&S.to>=C)){let S=A.moveToLineBoundary(Be.cursor(C),!1,!0).head;S>g&&(C=S)}let m=this.gapSize(d,g,C,B),v=t||m<2e6?m:2e6;f=new o4(g,C,m,v)}r.push(f)},l=g=>{if(g.length<a||g.type!=As.Text)return;let C=$cA(g.from,g.to,this.stateDeco);if(C.total<a)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,B,u;if(t){let E=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,f,m;if(d!=null){let v=Y6(C,d),S=((this.visibleBottom-this.visibleTop)/2+E)/g.height;f=v-S,m=v+S}else f=(this.visibleTop-g.top-E)/g.height,m=(this.visibleBottom-g.top+E)/g.height;B=J6(C,f),u=J6(C,m)}else{let E=C.total*this.heightOracle.charWidth,f=n*this.heightOracle.charWidth,m=0;if(E>2e6)for(let x of e)x.from>=g.from&&x.from<g.to&&x.size!=x.displaySize&&x.from*this.heightOracle.charWidth+m<this.pixelViewport.left&&(m=x.size-x.displaySize);let v=this.pixelViewport.left+m,S=this.pixelViewport.right+m,k,M;if(d!=null){let x=Y6(C,d),F=((S-v)/2+f)/E;k=x-F,M=x+F}else k=(v-f)/E,M=(S+f)/E;B=J6(C,k),u=J6(C,M)}B>g.from&&s(g.from,B,g,C),u<g.to&&s(u,g.to,g,C)};for(let g of this.viewportLines)Array.isArray(g.type)?g.type.forEach(l):l(g);return r}gapSize(e,A,t,n){let o=Y6(n,t)-Y6(n,A);return this.heightOracle.lineWrapping?e.height*o:n.total*this.heightOracle.charWidth*o}updateLineGaps(e){o4.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Lt.set(e.map(A=>A.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let A=this.stateDeco;this.lineGaps.length&&(A=A.concat(this.lineGapDeco));let t=[];uo.spans(A,this.viewport.from,this.viewport.to,{span(o,a){t.push({from:o,to:a})},point(){}},20);let n=0;if(t.length!=this.visibleRanges.length)n=12;else for(let o=0;o<t.length&&!(n&8);o++){let a=this.visibleRanges[o],r=t[o];(a.from!=r.from||a.to!=r.to)&&(n|=4,e&&e.mapPos(a.from,-1)==r.from&&e.mapPos(a.to,1)==r.to||(n|=8))}return this.visibleRanges=t,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(A=>A.from<=e&&A.to>=e)||Zu(this.heightMap.lineAt(e,Qa.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(A=>A.top<=e&&A.bottom>=e)||Zu(this.heightMap.lineAt(this.scaler.fromDOM(e),Qa.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let A=this.lineBlockAtHeight(e+8);return A.from>=this.viewport.from||this.viewportLines[0].top-e>200?A:this.viewportLines[0]}elementAtHeight(e){return Zu(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},$B=class{constructor(e,A){this.from=e,this.to=A}};function $cA(i,e,A){let t=[],n=i,o=0;return uo.spans(A,i,e,{span(){},point(a,r){a>n&&(t.push({from:n,to:a}),o+=a-n),n=r}},20),n<e&&(t.push({from:n,to:e}),o+=e-n),{total:o,ranges:t}}function J6({total:i,ranges:e},A){if(A<=0)return e[0].from;if(A>=1)return e[e.length-1].to;let t=Math.floor(i*A);for(let n=0;;n++){let{from:o,to:a}=e[n],r=a-o;if(t<=r)return o+t;t-=r}}function Y6(i,e){let A=0;for(let{from:t,to:n}of i.ranges){if(e<=n){A+=e-t;break}A+=n-t}return A/i.total}function A0A(i,e){for(let A of i)if(e(A))return A}var hY={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function EY(i){let e=i.facet(Q8).filter(t=>typeof t!="function"),A=i.facet(uS).filter(t=>typeof t!="function");return A.length&&e.push(uo.join(A)),e}var X9=class i{constructor(e,A,t){let n=0,o=0,a=0;this.viewports=t.map(({from:r,to:s})=>{let l=A.lineAt(r,Qa.ByPos,e,0,0).top,g=A.lineAt(s,Qa.ByPos,e,0,0).bottom;return n+=g-l,{from:r,to:s,top:l,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(A.height-n);for(let r of this.viewports)r.domTop=a+(r.top-o)*this.scale,a=r.domBottom=r.domTop+(r.bottom-r.top),o=r.bottom}toDOM(e){for(let A=0,t=0,n=0;;A++){let o=A<this.viewports.length?this.viewports[A]:null;if(!o||e<o.top)return n+(e-t)*this.scale;if(e<=o.bottom)return o.domTop+(e-o.top);t=o.bottom,n=o.domBottom}}fromDOM(e){for(let A=0,t=0,n=0;;A++){let o=A<this.viewports.length?this.viewports[A]:null;if(!o||e<o.domTop)return t+(e-n)/this.scale;if(e<=o.domBottom)return o.top+(e-o.domTop);t=o.bottom,n=o.domBottom}}eq(e){return e instanceof i?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((A,t)=>A.from==e.viewports[t].from&&A.to==e.viewports[t].to):!1}};function Zu(i,e){if(e.scale==1)return i;let A=e.toDOM(i.top),t=e.toDOM(i.bottom);return new ac(i.from,i.length,A,t-A,Array.isArray(i._content)?i._content.map(n=>Zu(n,e)):i._content)}var H6=nt.define({combine:i=>i.join(" ")}),I9=nt.define({combine:i=>i.indexOf(!0)>-1}),$9=Cg.newName(),uH=Cg.newName(),pH=Cg.newName(),fH={"&light":"."+uH,"&dark":"."+pH};function AS(i,e,A){return new Cg(e,{finish(t){return/&/.test(t)?t.replace(/&\w*/,n=>{if(n=="&")return i;if(!A||!A[n])throw new RangeError(`Unsupported selector: ${n}`);return A[n]}):i+" "+t}})}var e0A=AS("."+$9,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},fH),t0A={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},B9=Ct.ie&&Ct.ie_version<=11,eS=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new D9,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.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(A=>{for(let t of A)this.queue.push(t);(Ct.ie&&Ct.ie_version<=11||Ct.ios&&e.composing)&&A.some(t=>t.type=="childList"&&t.removedNodes.length||t.type=="characterData"&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ct.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ct.chrome&&Ct.chrome_version<126)&&(this.editContext=new tS(e),e.state.facet(lC)&&(e.contentDOM.editContext=this.editContext.editContext)),B9&&(this.onCharData=A=>{this.queue.push({target:A.target,type:"characterData",oldValue:A.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),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var A;((A=this.view.docView)===null||A===void 0?void 0:A.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(A=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),A.length>0&&A[A.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(A=>{A.length>0&&A[A.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((A,t)=>A!=e[t]))){this.gapIntersection.disconnect();for(let A of e)this.gapIntersection.observe(A);this.gaps=e}}onSelectionChange(e){let A=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:t}=this,n=this.selectionRange;if(t.state.facet(lC)?t.root.activeElement!=this.dom:!$u(this.dom,n))return;let o=n.anchorNode&&t.docView.tile.nearest(n.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){A||(this.selectionChanged=!1);return}(Ct.ie&&Ct.ie_version<=11||Ct.android&&Ct.chrome)&&!t.state.selection.main.empty&&n.focusNode&&A4(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,A=g4(e.root);if(!A)return!1;let t=Ct.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&i0A(this.view,A)||A;if(!t||this.selectionRange.eq(t))return!1;let n=$u(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&XgA(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,A){this.selectionRange.set(e.node,e.offset,A.node,A.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,A=null;for(let t=this.dom;t;)if(t.nodeType==1)!A&&e<this.scrollTargets.length&&this.scrollTargets[e]==t?e++:A||(A=this.scrollTargets.slice(0,e)),A&&A.push(t),t=t.assignedSlot||t.parentNode;else if(t.nodeType==11)t=t.host;else break;if(e<this.scrollTargets.length&&!A&&(A=this.scrollTargets.slice(0,e)),A){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=A)t.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,t0A),B9&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),B9&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,A){var t;if(!this.delayedAndroidKey){let n=()=>{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&ih(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:A,force:this.lastChange<Date.now()-50||!!(!((t=this.delayedAndroidKey)===null||t===void 0)&&t.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let A=-1,t=-1,n=!1;for(let o of e){let a=this.readMutation(o);a&&(a.typeOver&&(n=!0),A==-1?{from:A,to:t}=a:(A=Math.min(a.from,A),t=Math.max(a.to,t)))}return{from:A,to:t,typeOver:n}}readChange(){let{from:e,to:A,typeOver:t}=this.processRecords(),n=this.selectionChanged&&$u(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new J9(this.view,e,A,t);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let A=this.readChange();if(!A)return this.view.requestMeasure(),!1;let t=this.view.state,n=lH(this.view,A);return this.view.state==t&&(A.domChanged||A.newSel&&!r8(this.view.state.selection,A.newSel.main))&&this.view.update([]),n}readMutation(e){let A=this.view.docView.tile.nearest(e.target);if(!A||A.isWidget())return null;if(A.markDirty(e.type=="attributes"),e.type=="childList"){let t=QY(A,e.previousSibling||e.target.previousSibling,-1),n=QY(A,e.nextSibling||e.target.nextSibling,1);return{from:t?A.posAfter(t):A.posAtStart,to:n?A.posBefore(n):A.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:A.posAtStart,to:A.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(lC)!=e.state.facet(lC)&&(e.view.contentDOM.editContext=e.state.facet(lC)?this.editContext.editContext:null))}destroy(){var e,A,t;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(A=this.gapIntersection)===null||A===void 0||A.disconnect(),(t=this.resizeScroll)===null||t===void 0||t.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function QY(i,e,A){for(;e;){let t=_a.get(e);if(t&&t.parent==i)return t;let n=e.parentNode;e=n!=i.dom?n:A>0?e.nextSibling:e.previousSibling}return null}function uY(i,e){let A=e.startContainer,t=e.startOffset,n=e.endContainer,o=e.endOffset,a=i.docView.domAtPos(i.state.selection.main.anchor,1);return A4(a.node,a.offset,n,o)&&([A,t,n,o]=[n,o,A,t]),{anchorNode:A,anchorOffset:t,focusNode:n,focusOffset:o}}function i0A(i,e){if(e.getComposedRanges){let n=e.getComposedRanges(i.root)[0];if(n)return uY(i,n)}let A=null;function t(n){n.preventDefault(),n.stopImmediatePropagation(),A=n.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",t,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",t,!0),A?uY(i,A):null}var tS=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let A=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=t=>{let n=e.state.selection.main,{anchor:o,head:a}=n,r=this.toEditorPos(t.updateRangeStart),s=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:r,drifted:!1});let l=s-r>t.text.length;r==this.from&&o<this.from?r=o:s==this.to&&o>this.to&&(s=o);let g=gH(e.state.sliceDoc(r,s),t.text,(l?n.from:n.to)-r,l?"end":null);if(!g){let d=Be.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));r8(d,n)||e.dispatch({selection:d,userEvent:"select"});return}let C={from:g.from+r,to:g.toA+r,insert:On.of(t.text.slice(g.from,g.toB).split(` |
| 255 | -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,aS),Q0A={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},h9=null;function u0A(){var i;if(h9==null&&typeof document<"u"&&document.body){let e=document.body.style;h9=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return h9||!1}var Z6=nt.define({combine(i){let e=Lr(i,{render:null,specialChars:E0A,addSpecialChars:null});return(e.replaceTabs=!u0A())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,aS)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,aS)),e}});function _H(i={}){return[Z6.of(i),p0A()]}var vY=null;function p0A(){return vY||(vY=Po.fromClass(class{constructor(i){this.view=i,this.decorations=Lt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(Z6)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new oS({regexp:i.specialChars,decoration:(e,A,t)=>{let{doc:n}=A.state,o=$r(e[0],0);if(o==9){let a=n.lineAt(t),r=A.state.tabSize,s=rC(a.text,r,t-a.from);return Lt.replace({widget:new sS((r-s%r)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Lt.replace({widget:new rS(i,o)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(Z6);i.startState.facet(Z6)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}var f0A="\u2022";function m0A(i){return i>=32?f0A:i==10?"\u2424":String.fromCharCode(9216+i)}var rS=class extends gl{constructor(e,A){super(),this.options=e,this.code=A}eq(e){return e.code==this.code}toDOM(e){let A=m0A(this.code),t=e.state.phrase("Control character")+" "+(Q0A[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,t,A);if(n)return n;let o=document.createElement("span");return o.textContent=A,o.title=t,o.setAttribute("aria-label",t),o.className="cm-specialChar",o}ignoreEvent(){return!1}},sS=class extends gl{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function xH(){return y0A}var w0A=Lt.line({class:"cm-activeLine"}),y0A=Po.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,A=[];for(let t of i.state.selection.ranges){let n=i.lineBlockAt(t.head);n.from>e&&(A.push(w0A.range(n.from)),e=n.from)}return Lt.set(A)}},{decorations:i=>i.decorations});var lS=2e3;function D0A(i,e,A){let t=Math.min(e.line,A.line),n=Math.max(e.line,A.line),o=[];if(e.off>lS||A.off>lS||e.col<0||A.col<0){let a=Math.min(e.off,A.off),r=Math.max(e.off,A.off);for(let s=t;s<=n;s++){let l=i.doc.line(s);l.length<=r&&o.push(Be.range(l.from+a,l.to+r))}}else{let a=Math.min(e.col,A.col),r=Math.max(e.col,A.col);for(let s=t;s<=n;s++){let l=i.doc.line(s),g=G6(l.text,a,i.tabSize,!0);if(g<0)o.push(Be.cursor(l.to));else{let C=G6(l.text,r,i.tabSize);o.push(Be.range(l.from+g,l.from+C))}}}return o}function v0A(i,e){let A=i.coordsAtPos(i.viewport.from);return A?Math.round(Math.abs((A.left-e)/i.defaultCharacterWidth)):-1}function bY(i,e){let A=i.posAtCoords({x:e.clientX,y:e.clientY},!1),t=i.state.doc.lineAt(A),n=A-t.from,o=n>lS?-1:n==t.length?v0A(i,e.clientX):rC(t.text,i.state.tabSize,A-t.from);return{line:t.number,col:o,off:n}}function b0A(i,e){let A=bY(i,e),t=i.state.selection;return A?{update(n){if(n.docChanged){let o=n.changes.mapPos(n.startState.doc.line(A.line).from),a=n.state.doc.lineAt(o);A={line:a.number,col:A.col,off:Math.min(A.off,a.length)},t=t.map(n.changes)}},get(n,o,a){let r=bY(i,n);if(!r)return t;let s=D0A(i.state,A,r);return s.length?a?Be.create(s.concat(t.ranges)):Be.create(s):t}}:null}function RH(i){let e=i?.eventFilter||(A=>A.altKey&&A.button==0);return ui.mouseSelectionStyle.of((A,t)=>e(t)?b0A(A,t):null)}var M0A={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},S0A={style:"cursor: crosshair"};function NH(i={}){let[e,A]=M0A[i.key||"Alt"],t=Po.fromClass(class{constructor(n){this.view=n,this.isDown=!1}set(n){this.isDown!=n&&(this.isDown=n,this.view.update([]))}},{eventObservers:{keydown(n){this.set(n.keyCode==e||A(n))},keyup(n){(n.keyCode==e||!A(n))&&this.set(!1)},mousemove(n){this.set(A(n))}}});return[t,ui.contentAttributes.of(n=>{var o;return!((o=n.plugin(t))===null||o===void 0)&&o.isDown?S0A:null})]}var P6="-10000px",C8=class{constructor(e,A,t,n){this.facet=A,this.createTooltipView=t,this.removeTooltipView=n,this.input=e.state.facet(A),this.tooltips=this.input.filter(a=>a);let o=null;this.tooltipViews=this.tooltips.map(a=>o=t(a,o))}update(e,A){var t;let n=e.state.facet(this.facet),o=n.filter(s=>s);if(n===this.input){for(let s of this.tooltipViews)s.update&&s.update(e);return!1}let a=[],r=A?[]:null;for(let s=0;s<o.length;s++){let l=o[s],g=-1;if(l){for(let C=0;C<this.tooltips.length;C++){let d=this.tooltips[C];d&&d.create==l.create&&(g=C)}if(g<0)a[s]=this.createTooltipView(l,s?a[s-1]:null),r&&(r[s]=!!l.above);else{let C=a[s]=this.tooltipViews[g];r&&(r[s]=A[g]),C.update&&C.update(e)}}}for(let s of this.tooltipViews)a.indexOf(s)<0&&(this.removeTooltipView(s),(t=s.destroy)===null||t===void 0||t.call(s));return A&&(r.forEach((s,l)=>A[l]=s),A.length=r.length),this.input=n,this.tooltips=o,this.tooltipViews=a,!0}};function k0A(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var E9=nt.define({combine:i=>{var e,A,t;return{position:Ct.ios?"absolute":((e=i.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((A=i.find(n=>n.parent))===null||A===void 0?void 0:A.parent)||null,tooltipSpace:((t=i.find(n=>n.tooltipSpace))===null||t===void 0?void 0:t.tooltipSpace)||k0A}}}),MY=new WeakMap,mS=Po.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(E9);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new C8(i,ch,(A,t)=>this.createTooltip(A,t),A=>{this.resizeObserver&&this.resizeObserver.unobserve(A.dom),A.dom.remove()}),this.above=this.manager.tooltips.map(A=>!!A.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(A=>{Date.now()>this.lastTransaction-50&&A.length>0&&A[A.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let A=e||i.geometryChanged,t=i.state.facet(E9);if(t.position!=this.position&&!this.madeAbsolute){this.position=t.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;A=!0}if(t.parent!=this.parent){this.parent&&this.container.remove(),this.parent=t.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);A=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);A&&this.maybeMeasure()}createTooltip(i,e){let A=i.create(this.view),t=e?e.dom:null;if(A.dom.classList.add("cm-tooltip"),i.arrow&&!A.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",A.dom.appendChild(n)}return A.dom.style.position=this.position,A.dom.style.top=P6,A.dom.style.left="0px",this.container.insertBefore(A.dom,t),A.mount&&A.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(A.dom),A}destroy(){var i,e,A;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(i=t.destroy)===null||i===void 0||i.call(t);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(A=this.intersectionObserver)===null||A===void 0||A.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,A=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(Ct.safari){let a=o.getBoundingClientRect();A=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else A=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(A||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(i=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let t=this.view.scrollDOM.getBoundingClientRect(),n=pS(this.view);return{visible:{left:t.left+n.left,top:t.top+n.top,right:t.right-n.right,bottom:t.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,a)=>{let r=this.manager.tooltipViews[a];return r.getCoords?r.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(E9).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:A}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let r of this.manager.tooltipViews)r.dom.style.position="absolute"}let{visible:A,space:t,scaleX:n,scaleY:o}=i,a=[];for(let r=0;r<this.manager.tooltips.length;r++){let s=this.manager.tooltips[r],l=this.manager.tooltipViews[r],{dom:g}=l,C=i.pos[r],d=i.size[r];if(!C||s.clip!==!1&&(C.bottom<=Math.max(A.top,t.top)||C.top>=Math.min(A.bottom,t.bottom)||C.right<Math.max(A.left,t.left)-.1||C.left>Math.min(A.right,t.right)+.1)){g.style.top=P6;continue}let B=s.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=B?7:0,E=d.right-d.left,f=(e=MY.get(l))!==null&&e!==void 0?e:d.bottom-d.top,m=l.offset||x0A,v=this.view.textDirection==Lo.LTR,S=d.width>t.right-t.left?v?t.left:t.right-d.width:v?Math.max(t.left,Math.min(C.left-(B?14:0)+m.x,t.right-E)):Math.min(Math.max(t.left,C.left-E+(B?14:0)-m.x),t.right-E),k=this.above[r];!s.strictSide&&(k?C.top-f-u-m.y<t.top:C.bottom+f+u+m.y>t.bottom)&&k==t.bottom-C.bottom>C.top-t.top&&(k=this.above[r]=!k);let M=(k?C.top-t.top:t.bottom-C.bottom)-u;if(M<f&&l.resize!==!1){if(M<this.view.defaultLineHeight){g.style.top=P6;continue}MY.set(l,f),g.style.height=(f=M)/o+"px"}else g.style.height&&(g.style.height="");let x=k?C.top-f-u-m.y:C.bottom+u+m.y,F=S+E;if(l.overlap!==!0)for(let z of a)z.left<F&&z.right>S&&z.top<x+f&&z.bottom>x&&(x=k?z.top-f-2-u:z.bottom+u+2);if(this.position=="absolute"?(g.style.top=(x-i.parent.top)/o+"px",SY(g,(S-i.parent.left)/n)):(g.style.top=x/o+"px",SY(g,S/n)),B){let z=C.left+(v?m.x:-m.x)-(S+14-7);B.style.left=z/n+"px"}l.overlap!==!0&&a.push({left:S,top:x,right:F,bottom:x+f}),g.classList.toggle("cm-tooltip-above",k),g.classList.toggle("cm-tooltip-below",!k),l.positioned&&l.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=P6}},{eventObservers:{scroll(){this.maybeMeasure()}}});function SY(i,e){let A=parseInt(i.style.left,10);(isNaN(A)||Math.abs(e-A)>1)&&(i.style.left=e+"px")}var _0A=ui.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),x0A={x:0,y:0},ch=nt.define({enables:[mS,_0A]}),d8=nt.define({combine:i=>i.reduce((e,A)=>e.concat(A),[])}),I8=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new C8(e,d8,(A,t)=>this.createHostedView(A,t),A=>A.dom.remove())}createHostedView(e,A){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(t.dom,A?A.dom.nextSibling:this.dom.firstChild),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let A of this.manager.tooltipViews)A.mount&&A.mount(e);this.mounted=!0}positioned(e){for(let A of this.manager.tooltipViews)A.positioned&&A.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let A of this.manager.tooltipViews)(e=A.destroy)===null||e===void 0||e.call(A)}passProp(e){let A;for(let t of this.manager.tooltipViews){let n=t[e];if(n!==void 0){if(A===void 0)A=n;else if(A!==n)return}}return A}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},R0A=ch.compute([d8],i=>{let e=i.facet(d8);return e.length===0?null:{pos:Math.min(...e.map(A=>A.pos)),end:Math.max(...e.map(A=>{var t;return(t=A.end)!==null&&t!==void 0?t:A.pos})),create:I8.create,above:e[0].above,arrow:e.some(A=>A.arrow)}}),gS=class{constructor(e,A,t,n,o){this.view=e,this.source=A,this.field=t,this.setHover=n,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:A}=this,t=e.docView.tile.nearest(A.target);if(!t)return;let n,o=1;if(t.isWidget())n=t.posAtStart;else{if(n=e.posAtCoords(A),n==null)return;let r=e.coordsAtPos(n);if(!r||A.y<r.top||A.y>r.bottom||A.x<r.left-e.defaultCharacterWidth||A.x>r.right+e.defaultCharacterWidth)return;let s=e.bidiSpans(e.state.doc.lineAt(n)).find(g=>g.from<=n&&g.to>=n),l=s&&s.dir==Lo.RTL?-1:1;o=A.x<r.left?-l:l}let a=this.source(e,n,o);if(a?.then){let r=this.pending={pos:n};a.then(s=>{this.pending==r&&(this.pending=null,s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])}))},s=>Gr(e.state,s,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(mS),A=e?e.manager.tooltips.findIndex(t=>t.create==I8.create):-1;return A>-1?e.manager.tooltipViews[A]:null}mousemove(e){var A,t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:o}=this;if(n.length&&o&&!N0A(o.dom,e)||this.pending){let{pos:a}=n[0]||this.pending,r=(t=(A=n[0])===null||A===void 0?void 0:A.end)!==null&&t!==void 0?t:a;(a==r?this.view.posAtCoords(this.lastMove)!=a:!F0A(this.view,a,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:A}=this;if(A.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let A=t=>{e.removeEventListener("mouseleave",A),this.active.length&&!this.view.dom.contains(t.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",A)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},j6=4;function N0A(i,e){let{left:A,right:t,top:n,bottom:o}=i.getBoundingClientRect(),a;if(a=i.querySelector(".cm-tooltip-arrow")){let r=a.getBoundingClientRect();n=Math.min(r.top,n),o=Math.max(r.bottom,o)}return e.clientX>=A-j6&&e.clientX<=t+j6&&e.clientY>=n-j6&&e.clientY<=o+j6}function F0A(i,e,A,t,n,o){let a=i.scrollDOM.getBoundingClientRect(),r=i.documentTop+i.documentPadding.top+i.contentHeight;if(a.left>t||a.right<t||a.top>n||Math.min(a.bottom,r)<n)return!1;let s=i.posAtCoords({x:t,y:n},!1);return s>=e&&s<=A}function FH(i,e={}){let A=ln.define(),t=La.define({create(){return[]},update(n,o){if(n.length&&(e.hideOnChange&&(o.docChanged||o.selection)?n=[]:e.hideOn&&(n=n.filter(a=>!e.hideOn(o,a))),o.docChanged)){let a=[];for(let r of n){let s=o.changes.mapPos(r.pos,-1,Wr.TrackDel);if(s!=null){let l=Object.assign(Object.create(null),r);l.pos=s,l.end!=null&&(l.end=o.changes.mapPos(l.end)),a.push(l)}}n=a}for(let a of o.effects)a.is(A)&&(n=a.value),a.is(L0A)&&(n=[]);return n},provide:n=>d8.from(n)});return{active:t,extension:[t,Po.define(n=>new gS(n,i,t,A,e.hoverTime||300)),R0A]}}function wS(i,e){let A=i.plugin(mS);if(!A)return null;let t=A.manager.tooltips.indexOf(e);return t<0?null:A.manager.tooltipViews[t]}var L0A=ln.define();var kY=nt.define({combine(i){let e,A;for(let t of i)e=e||t.topContainer,A=A||t.bottomContainer;return{topContainer:e,bottomContainer:A}}});function d4(i,e){let A=i.plugin(LH),t=A?A.specs.indexOf(e):-1;return t>-1?A.panels[t]:null}var LH=Po.fromClass(class{constructor(i){this.input=i.state.facet(vd),this.specs=this.input.filter(A=>A),this.panels=this.specs.map(A=>A(i));let e=i.state.facet(kY);this.top=new Ah(i,!0,e.topContainer),this.bottom=new Ah(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(A=>A.top)),this.bottom.sync(this.panels.filter(A=>!A.top));for(let A of this.panels)A.dom.classList.add("cm-panel"),A.mount&&A.mount()}update(i){let e=i.state.facet(kY);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ah(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ah(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let A=i.state.facet(vd);if(A!=this.input){let t=A.filter(s=>s),n=[],o=[],a=[],r=[];for(let s of t){let l=this.specs.indexOf(s),g;l<0?(g=s(i.view),r.push(g)):(g=this.panels[l],g.update&&g.update(i)),n.push(g),(g.top?o:a).push(g)}this.specs=t,this.panels=n,this.top.sync(o),this.bottom.sync(a);for(let s of r)s.dom.classList.add("cm-panel"),s.mount&&s.mount()}else for(let t of this.panels)t.update&&t.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>ui.scrollMargins.of(e=>{let A=e.plugin(i);return A&&{top:A.top.scrollMargin(),bottom:A.bottom.scrollMargin()}})}),Ah=class{constructor(e,A,t){this.view=e,this.top=A,this.container=t,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let A of this.panels)A.destroy&&e.indexOf(A)<0&&A.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let A=this.container||this.view.dom;A.insertBefore(this.dom,this.top?A.firstChild:null)}let e=this.dom.firstChild;for(let A of this.panels)if(A.dom.parentNode==this.dom){for(;e!=A.dom;)e=_Y(e);e=e.nextSibling}else this.dom.insertBefore(A.dom,e);for(;e;)e=_Y(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function _Y(i){let e=i.nextSibling;return i.remove(),e}var vd=nt.define({enables:LH});function GH(i,e){let A,t=new Promise(a=>A=a),n=a=>G0A(a,e,A);i.state.field(Q9,!1)?i.dispatch({effects:KH.of(n)}):i.dispatch({effects:ln.appendConfig.of(Q9.init(()=>[n]))});let o=UH.of(n);return{close:o,result:t.then(a=>((i.win.queueMicrotask||(s=>i.win.setTimeout(s,10)))(()=>{i.state.field(Q9).indexOf(n)>-1&&i.dispatch({effects:o})}),a))}}var Q9=La.define({create(){return[]},update(i,e){for(let A of e.effects)A.is(KH)?i=[A.value].concat(i):A.is(UH)&&(i=i.filter(t=>t!=A.value));return i},provide:i=>vd.computeN([i],e=>e.field(i))}),KH=ln.define(),UH=ln.define();function G0A(i,e,A){let t=e.content?e.content(i,()=>a(null)):null;if(!t){if(t=po("form"),e.input){let r=po("input",e.input);/^(text|password|number|email|tel|url)$/.test(r.type)&&r.classList.add("cm-textfield"),r.name||(r.name="input"),t.appendChild(po("label",(e.label||"")+": ",r))}else t.appendChild(document.createTextNode(e.label||""));t.appendChild(document.createTextNode(" ")),t.appendChild(po("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n=t.nodeName=="FORM"?[t]:t.querySelectorAll("form");for(let r=0;r<n.length;r++){let s=n[r];s.addEventListener("keydown",l=>{l.keyCode==27?(l.preventDefault(),a(null)):l.keyCode==13&&(l.preventDefault(),a(s))}),s.addEventListener("submit",l=>{l.preventDefault(),a(s)})}let o=po("div",t,po("button",{onclick:()=>a(null),"aria-label":i.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));e.class&&(o.className=e.class),o.classList.add("cm-dialog");function a(r){o.contains(o.ownerDocument.activeElement)&&i.focus(),A(r)}return{dom:o,top:e.top,mount:()=>{if(e.focus){let r;typeof e.focus=="string"?r=t.querySelector(e.focus):r=t.querySelector("input")||t.querySelector("button"),r&&"select"in r?r.select():r&&"focus"in r&&r.focus()}}}}var Cl=class extends cg{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Cl.prototype.elementClass="";Cl.prototype.toDOM=void 0;Cl.prototype.mapMode=Wr.TrackBefore;Cl.prototype.startSide=Cl.prototype.endSide=-1;Cl.prototype.point=!0;var X6=nt.define(),K0A=nt.define(),U0A={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>uo.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},a4=nt.define();function p8(i){return[TH(),a4.of(P(P({},U0A),i))]}var cS=nt.define({combine:i=>i.some(e=>e)});function TH(i){let e=[T0A];return i&&i.fixed===!1&&e.push(cS.of(!0)),e}var T0A=Po.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(a4).map(e=>new B8(i,e)),this.fixed=!i.state.facet(cS);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,A=i.view.viewport,t=Math.min(e.to,A.to)-Math.max(e.from,A.from);this.syncGutters(t<(A.to-A.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(cS)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let A=uo.iter(this.view.state.facet(X6),this.view.viewport.from),t=[],n=this.gutters.map(o=>new dS(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(t.length&&(t=[]),Array.isArray(o.type)){let a=!0;for(let r of o.type)if(r.type==As.Text&&a){CS(A,t,r.from);for(let s of n)s.line(this.view,r,t);a=!1}else if(r.widget)for(let s of n)s.widget(this.view,r)}else if(o.type==As.Text){CS(A,t,o.from);for(let a of n)a.line(this.view,o,t)}else if(o.widget)for(let a of n)a.widget(this.view,o);for(let o of n)o.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(a4),A=i.state.facet(a4),t=i.docChanged||i.heightChanged||i.viewportChanged||!uo.eq(i.startState.facet(X6),i.state.facet(X6),i.view.viewport.from,i.view.viewport.to);if(e==A)for(let n of this.gutters)n.update(i)&&(t=!0);else{t=!0;let n=[];for(let o of A){let a=e.indexOf(o);a<0?n.push(new B8(this.view,o)):(this.gutters[a].update(i),n.push(this.gutters[a]))}for(let o of this.gutters)o.dom.remove(),n.indexOf(o)<0&&o.destroy();for(let o of n)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=n}return t}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>ui.scrollMargins.of(e=>{let A=e.plugin(i);if(!A||A.gutters.length==0||!A.fixed)return null;let t=A.dom.offsetWidth*e.scaleX,n=A.domAfter?A.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Lo.LTR?{left:t,right:n}:{right:t,left:n}})});function xY(i){return Array.isArray(i)?i:[i]}function CS(i,e,A){for(;i.value&&i.from<=A;)i.from==A&&e.push(i.value),i.next()}var dS=class{constructor(e,A,t){this.gutter=e,this.height=t,this.i=0,this.cursor=uo.iter(e.markers,A.from)}addElement(e,A,t){let{gutter:n}=this,o=(A.top-this.height)/e.scaleY,a=A.height/e.scaleY;if(this.i==n.elements.length){let r=new h8(e,a,o,t);n.elements.push(r),n.dom.appendChild(r.dom)}else n.elements[this.i].update(e,a,o,t);this.height=A.bottom,this.i++}line(e,A,t){let n=[];CS(this.cursor,n,A.from),t.length&&(n=n.concat(t));let o=this.gutter.config.lineMarker(e,A,n);o&&n.unshift(o);let a=this.gutter;n.length==0&&!a.config.renderEmptyElements||this.addElement(e,A,n)}widget(e,A){let t=this.gutter.config.widgetMarker(e,A.widget,A),n=t?[t]:null;for(let o of e.state.facet(K0A)){let a=o(e,A.widget,A);a&&(n||(n=[])).push(a)}n&&this.addElement(e,A,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let A=e.elements.pop();e.dom.removeChild(A.dom),A.destroy()}}},B8=class{constructor(e,A){this.view=e,this.config=A,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let t in A.domEventHandlers)this.dom.addEventListener(t,n=>{let o=n.target,a;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let s=o.getBoundingClientRect();a=(s.top+s.bottom)/2}else a=n.clientY;let r=e.lineBlockAtHeight(a-e.documentTop);A.domEventHandlers[t](e,r,n)&&n.preventDefault()});this.markers=xY(A.markers(e)),A.initialSpacer&&(this.spacer=new h8(e,0,0,[A.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let A=this.markers;if(this.markers=xY(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let t=e.view.viewport;return!uo.eq(this.markers,A,t.from,t.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},h8=class{constructor(e,A,t,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,A,t,n)}update(e,A,t,n){this.height!=A&&(this.height=A,this.dom.style.height=A+"px"),this.above!=t&&(this.dom.style.marginTop=(this.above=t)?t+"px":""),O0A(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,A){let t="cm-gutterElement",n=this.dom.firstChild;for(let o=0,a=0;;){let r=a,s=o<A.length?A[o++]:null,l=!1;if(s){let g=s.elementClass;g&&(t+=" "+g);for(let C=a;C<this.markers.length;C++)if(this.markers[C].compare(s)){r=C,l=!0;break}}else r=this.markers.length;for(;a<r;){let g=this.markers[a++];if(g.toDOM){g.destroy(n);let C=n.nextSibling;n.remove(),n=C}}if(!s)break;s.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(s.toDOM(e),n)),l&&a++}this.dom.className=t,this.markers=A}destroy(){this.setMarkers(null,[])}};function O0A(i,e){if(i.length!=e.length)return!1;for(let A=0;A<i.length;A++)if(!i[A].compare(e[A]))return!1;return!0}var J0A=nt.define(),Y0A=nt.define(),eh=nt.define({combine(i){return Lr(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,A){let t=Object.assign({},e);for(let n in A){let o=t[n],a=A[n];t[n]=o?(r,s,l)=>o(r,s,l)||a(r,s,l):a}return t}})}}),r4=class extends Cl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function u9(i,e){return i.state.facet(eh).formatNumber(e,i.state)}var H0A=a4.compute([eh],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(J0A)},lineMarker(e,A,t){return t.some(n=>n.toDOM)?null:new r4(u9(e,e.state.doc.lineAt(A.from).number))},widgetMarker:(e,A,t)=>{for(let n of e.state.facet(Y0A)){let o=n(e,A,t);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(eh)!=e.state.facet(eh),initialSpacer(e){return new r4(u9(e,RY(e.state.doc.lines)))},updateSpacer(e,A){let t=u9(A.view,RY(A.view.state.doc.lines));return t==e.number?e:new r4(t)},domEventHandlers:i.facet(eh).domEventHandlers,side:"before"}));function OH(i={}){return[eh.of(i),TH(),H0A]}function RY(i){let e=9;for(;e<i;)e=e*10+9;return e}var z0A=new class extends Cl{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},P0A=X6.compute(["selection"],i=>{let e=[],A=-1;for(let t of i.selection.ranges){let n=i.doc.lineAt(t.head).from;n>A&&(A=n,e.push(z0A.range(n)))}return uo.of(e)});function JH(){return P0A}var j0A=0,I4=class{constructor(e,A){this.from=e,this.to=A}},Hi=class{constructor(e={}){this.id=j0A++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ys.match(e)),A=>{let t=e(A);return t===void 0?null:[this,t]}}};Hi.closedBy=new Hi({deserialize:i=>i.split(" ")});Hi.openedBy=new Hi({deserialize:i=>i.split(" ")});Hi.group=new Hi({deserialize:i=>i.split(" ")});Hi.isolate=new Hi({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});Hi.contextHash=new Hi({perNode:!0});Hi.lookAhead=new Hi({perNode:!0});Hi.mounted=new Hi({perNode:!0});var bd=class{constructor(e,A,t,n=!1){this.tree=e,this.overlay=A,this.parser=t,this.bracketed=n}static get(e){return e&&e.props&&e.props[Hi.mounted.id]}},V0A=Object.create(null),ys=class i{constructor(e,A,t,n=0){this.name=e,this.props=A,this.id=t,this.flags=n}static define(e){let A=e.props&&e.props.length?Object.create(null):V0A,t=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new i(e.name||"",A,e.id,t);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(n)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");A[o[0].id]=o[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let A=this.prop(Hi.group);return A?A.indexOf(e)>-1:!1}return this.id==e}static match(e){let A=Object.create(null);for(let t in e)for(let n of t.split(" "))A[n]=e[t];return t=>{for(let n=t.prop(Hi.group),o=-1;o<(n?n.length:0);o++){let a=A[o<0?t.name:n[o]];if(a)return a}}}};ys.none=new ys("",Object.create(null),0,8);var B4=class i{constructor(e){this.types=e;for(let A=0;A<e.length;A++)if(e[A].id!=A)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let A=[];for(let t of this.types){let n=null;for(let o of e){let a=o(t);if(a){n||(n=Object.assign({},t.props));let r=a[1],s=a[0];s.combine&&s.id in n&&(r=s.combine(n[s.id],r)),n[s.id]=r}}A.push(n?new ys(t.name,n,t.id,t.flags):t)}return new i(A)}},f8=new WeakMap,YH=new WeakMap,Ga=(function(i){return i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed",i})(Ga||{}),Pa=class i{constructor(e,A,t,n,o){if(this.type=e,this.children=A,this.positions=t,this.length=n,this.props=null,o&&o.length){this.props=Object.create(null);for(let[a,r]of o)this.props[typeof a=="number"?a:a.id]=r}}toString(){let e=bd.get(this);if(e&&!e.overlay)return e.tree.toString();let A="";for(let t of this.children){let n=t.toString();n&&(A&&(A+=","),A+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(A.length?"("+A+")":""):A}cursor(e=0){return new Q4(this.topNode,e)}cursorAt(e,A=0,t=0){let n=f8.get(this)||this.topNode,o=new Q4(n);return o.moveTo(e,A),f8.set(this,o._tree),o}get topNode(){return new d0(this,0,0,null)}resolve(e,A=0){let t=h4(f8.get(this)||this.topNode,e,A,!1);return f8.set(this,t),t}resolveInner(e,A=0){let t=h4(YH.get(this)||this.topNode,e,A,!0);return YH.set(this,t),t}resolveStack(e,A=0){return q0A(this,e,A)}iterate(e){let{enter:A,leave:t,from:n=0,to:o=this.length}=e,a=e.mode||0,r=(a&Ga.IncludeAnonymous)>0;for(let s=this.cursor(a|Ga.IncludeAnonymous);;){let l=!1;if(s.from<=o&&s.to>=n&&(!r&&s.type.isAnonymous||A(s)!==!1)){if(s.firstChild())continue;l=!0}for(;l&&t&&(r||!s.type.isAnonymous)&&t(s),!s.nextSibling();){if(!s.parent())return;l=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let A in this.props)e.push([+A,this.props[A]]);return e}balance(e={}){return this.children.length<=8?this:kS(ys.none,this.children,this.positions,0,this.children.length,0,this.length,(A,t,n)=>new i(this.type,A,t,n,this.propValues),e.makeTree||((A,t,n)=>new i(ys.none,A,t,n)))}static build(e){return W0A(e)}};Pa.empty=new Pa(ys.none,[],[],0);var yS=class i{constructor(e,A){this.buffer=e,this.index=A}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new i(this.buffer,this.index)}},k2=class i{constructor(e,A,t){this.buffer=e,this.length=A,this.set=t}get type(){return ys.none}toString(){let e=[];for(let A=0;A<this.buffer.length;)e.push(this.childString(A)),A=this.buffer[A+3];return e.join(",")}childString(e){let A=this.buffer[e],t=this.buffer[e+3],n=this.set.types[A],o=n.name;if(/\W/.test(o)&&!n.isError&&(o=JSON.stringify(o)),e+=4,t==e)return o;let a=[];for(;e<t;)a.push(this.childString(e)),e=this.buffer[e+3];return o+"("+a.join(",")+")"}findChild(e,A,t,n,o){let{buffer:a}=this,r=-1;for(let s=e;s!=A&&!(PH(o,n,a[s+1],a[s+2])&&(r=s,t>0));s=a[s+3]);return r}slice(e,A,t){let n=this.buffer,o=new Uint16Array(A-e),a=0;for(let r=e,s=0;r<A;){o[s++]=n[r++],o[s++]=n[r++]-t;let l=o[s++]=n[r++]-t;o[s++]=n[r++]-e,a=Math.max(a,l)}return new i(o,a,this.set)}};function PH(i,e,A,t){switch(i){case-2:return A<e;case-1:return t>=e&&A<e;case 0:return A<e&&t>e;case 1:return A<=e&&t>e;case 2:return t>e;case 4:return!0}}function h4(i,e,A,t){for(var n;i.from==i.to||(A<1?i.from>=e:i.from>e)||(A>-1?i.to<=e:i.to<e);){let a=!t&&i instanceof d0&&i.index<0?null:i.parent;if(!a)return i;i=a}let o=t?0:Ga.IgnoreOverlays;if(t)for(let a=i,r=a.parent;r;a=r,r=a.parent)a instanceof d0&&a.index<0&&((n=r.enter(e,A,o))===null||n===void 0?void 0:n.from)!=a.from&&(i=r);for(;;){let a=i.enter(e,A,o);if(!a)return i;i=a}}var w8=class{cursor(e=0){return new Q4(this,e)}getChild(e,A=null,t=null){let n=HH(this,e,A,t);return n.length?n[0]:null}getChildren(e,A=null,t=null){return HH(this,e,A,t)}resolve(e,A=0){return h4(this,e,A,!1)}resolveInner(e,A=0){return h4(this,e,A,!0)}matchContext(e){return DS(this.parent,e)}enterUnfinishedNodesBefore(e){let A=this.childBefore(e),t=this;for(;A;){let n=A.lastChild;if(!n||n.to!=A.to)break;n.type.isError&&n.from==n.to?(t=A,A=n.prevSibling):A=n}return t}get node(){return this}get next(){return this.parent}},d0=class i extends w8{constructor(e,A,t,n){super(),this._tree=e,this.from=A,this.index=t,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,A,t,n,o=0){for(let a=this;;){for(let{children:r,positions:s}=a._tree,l=A>0?r.length:-1;e!=l;e+=A){let g=r[e],C=s[e]+a.from,d;if(!(!(o&Ga.EnterBracketed&&g instanceof Pa&&(d=bd.get(g))&&!d.overlay&&d.bracketed&&t>=C&&t<=C+g.length)&&!PH(n,t,C,C+g.length))){if(g instanceof k2){if(o&Ga.ExcludeBuffers)continue;let B=g.findChild(0,g.buffer.length,A,t-C,n);if(B>-1)return new E4(new vS(a,g,e,C),null,B)}else if(o&Ga.IncludeAnonymous||!g.type.isAnonymous||SS(g)){let B;if(!(o&Ga.IgnoreMounts)&&(B=bd.get(g))&&!B.overlay)return new i(B.tree,C,e,a);let u=new i(g,C,e,a);return o&Ga.IncludeAnonymous||!u.type.isAnonymous?u:u.nextChild(A<0?g.children.length-1:0,A,t,n,o)}}}if(o&Ga.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+A:e=A<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,A,t=0){let n;if(!(t&Ga.IgnoreOverlays)&&(n=bd.get(this._tree))&&n.overlay){let o=e-this.from,a=t&Ga.EnterBracketed&&n.bracketed;for(let{from:r,to:s}of n.overlay)if((A>0||a?r<=o:r<o)&&(A<0||a?s>=o:s>o))return new i(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,A,t)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function HH(i,e,A,t){let n=i.cursor(),o=[];if(!n.firstChild())return o;if(A!=null){for(let a=!1;!a;)if(a=n.type.is(A),!n.nextSibling())return o}for(;;){if(t!=null&&n.type.is(t))return o;if(n.type.is(e)&&o.push(n.node),!n.nextSibling())return t==null?o:[]}}function DS(i,e,A=e.length-1){for(let t=i;A>=0;t=t.parent){if(!t)return!1;if(!t.type.isAnonymous){if(e[A]&&e[A]!=t.name)return!1;A--}}return!0}var vS=class{constructor(e,A,t,n){this.parent=e,this.buffer=A,this.index=t,this.start=n}},E4=class i extends w8{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,A,t){super(),this.context=e,this._parent=A,this.index=t,this.type=e.buffer.set.types[e.buffer.buffer[t]]}child(e,A,t){let{buffer:n}=this.context,o=n.findChild(this.index+4,n.buffer[this.index+3],e,A-this.context.start,t);return o<0?null:new i(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,A,t=0){if(t&Ga.ExcludeBuffers)return null;let{buffer:n}=this.context,o=n.findChild(this.index+4,n.buffer[this.index+3],A>0?1:-1,e-this.context.start,A);return o<0?null:new i(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,A=e.buffer[this.index+3];return A<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,A):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,A=this._parent?this._parent.index+4:0;return this.index==A?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(A,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],A=[],{buffer:t}=this.context,n=this.index+4,o=t.buffer[this.index+3];if(o>n){let a=t.buffer[this.index+1];e.push(t.slice(n,o,a)),A.push(0)}return new Pa(this.type,e,A,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function jH(i){if(!i.length)return null;let e=0,A=i[0];for(let o=1;o<i.length;o++){let a=i[o];(a.from>A.from||a.to<A.to)&&(A=a,e=o)}let t=A instanceof d0&&A.index<0?null:A.parent,n=i.slice();return t?n[e]=t:n.splice(e,1),new bS(n,A)}var bS=class{constructor(e,A){this.heads=e,this.node=A}get next(){return jH(this.heads)}};function q0A(i,e,A){let t=i.resolveInner(e,A),n=null;for(let o=t instanceof d0?t:t.context.parent;o;o=o.parent)if(o.index<0){let a=o.parent;(n||(n=[t])).push(a.resolve(e,A)),o=a}else{let a=bd.get(o.tree);if(a&&a.overlay&&a.overlay[0].from<=e&&a.overlay[a.overlay.length-1].to>=e){let r=new d0(a.tree,a.overlay[0].from+o.from,-1,o);(n||(n=[t])).push(h4(r,e,A,!1))}}return n?jH(n):t}var Q4=class{get name(){return this.type.name}constructor(e,A=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=A&~Ga.EnterBracketed,e instanceof d0)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,A){this.index=e;let{start:t,buffer:n}=this.buffer;return this.type=A||n.set.types[n.buffer[e]],this.from=t+n.buffer[e+1],this.to=t+n.buffer[e+2],!0}yield(e){return e?e instanceof d0?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,A,t){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,A,t,this.mode));let{buffer:n}=this.buffer,o=n.findChild(this.index+4,n.buffer[this.index+3],e,A-this.buffer.start,t);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,A,t=this.mode){return this.buffer?t&Ga.ExcludeBuffers?!1:this.enterChild(1,e,A):this.yield(this._tree.enter(e,A,t))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ga.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ga.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:A}=this.buffer,t=this.stack.length-1;if(e<0){let n=t<0?0:this.stack[t]+4;if(this.index!=n)return this.yieldBuf(A.findChild(n,this.index,-1,0,4))}else{let n=A.buffer[this.index+3];if(n<(t<0?A.buffer.length:A.buffer[this.stack[t]+3]))return this.yieldBuf(n)}return t<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let A,t,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(n.buffer.buffer[o+3]<this.index)return!1;({index:A,parent:t}=n)}else({index:A,_parent:t}=this._tree);for(;t;{index:A,_parent:t}=t)if(A>-1)for(let o=A+e,a=e<0?-1:t._tree.children.length;o!=a;o+=e){let r=t._tree.children[o];if(this.mode&Ga.IncludeAnonymous||r instanceof k2||!r.type.isAnonymous||SS(r))return!1}return!0}move(e,A){if(A&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,A=0){for(;(this.from==this.to||(A<1?this.from>=e:this.from>e)||(A>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,A););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,A=null,t=0;if(e&&e.context==this.buffer)A:for(let n=this.index,o=this.stack.length;o>=0;){for(let a=e;a;a=a._parent)if(a.index==n){if(n==this.index)return a;A=a,t=o+1;break A}n=this.stack[--o]}for(let n=t;n<this.stack.length;n++)A=new E4(this.buffer,A,this.stack[n]);return this.bufferNode=new E4(this.buffer,A,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,A){for(let t=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){t++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&A&&A(this),n=this.type.isAnonymous,!t)return;if(this.nextSibling())break;this.parent(),t--,n=!0}}}matchContext(e){if(!this.buffer)return DS(this.node.parent,e);let{buffer:A}=this.buffer,{types:t}=A.set;for(let n=e.length-1,o=this.stack.length-1;n>=0;o--){if(o<0)return DS(this._tree,e,n);let a=t[A.buffer[this.stack[o]]];if(!a.isAnonymous){if(e[n]&&e[n]!=a.name)return!1;n--}}return!0}};function SS(i){return i.children.some(e=>e instanceof k2||!e.type.isAnonymous||SS(e))}function W0A(i){var e;let{buffer:A,nodeSet:t,maxBufferLength:n=1024,reused:o=[],minRepeatType:a=t.types.length}=i,r=Array.isArray(A)?new yS(A,A.length):A,s=t.types,l=0,g=0;function C(M,x,F,z,j,X){let{id:eA,start:Z,end:CA,size:wA}=r,BA=g,QA=l;if(wA<0)if(r.next(),wA==-1){let qA=o[eA];F.push(qA),z.push(Z-M);return}else if(wA==-3){l=eA;return}else if(wA==-4){g=eA;return}else throw new RangeError(`Unrecognized record size: ${wA}`);let RA=s[eA],dA,IA,xA=Z-M;if(CA-Z<=n&&(IA=f(r.pos-x,j))){let qA=new Uint16Array(IA.size-IA.skip),ue=r.pos-IA.size,HA=qA.length;for(;r.pos>ue;)HA=m(IA.start,qA,HA);dA=new k2(qA,CA-IA.start,t),xA=IA.start-M}else{let qA=r.pos-wA;r.next();let ue=[],HA=[],bA=eA>=a?eA:-1,PA=0,it=CA;for(;r.pos>qA;)bA>=0&&r.id==bA&&r.size>=0?(r.end<=it-n&&(u(ue,HA,Z,PA,r.end,it,bA,BA,QA),PA=ue.length,it=r.end),r.next()):X>2500?d(Z,qA,ue,HA):C(Z,qA,ue,HA,bA,X+1);if(bA>=0&&PA>0&&PA<ue.length&&u(ue,HA,Z,PA,Z,it,bA,BA,QA),ue.reverse(),HA.reverse(),bA>-1&&PA>0){let Xe=B(RA,QA);dA=kS(RA,ue,HA,0,ue.length,0,CA-Z,Xe,Xe)}else dA=E(RA,ue,HA,CA-Z,BA-CA,QA)}F.push(dA),z.push(xA)}function d(M,x,F,z){let j=[],X=0,eA=-1;for(;r.pos>x;){let{id:Z,start:CA,end:wA,size:BA}=r;if(BA>4)r.next();else{if(eA>-1&&CA<eA)break;eA<0&&(eA=wA-n),j.push(Z,CA,wA),X++,r.next()}}if(X){let Z=new Uint16Array(X*4),CA=j[j.length-2];for(let wA=j.length-3,BA=0;wA>=0;wA-=3)Z[BA++]=j[wA],Z[BA++]=j[wA+1]-CA,Z[BA++]=j[wA+2]-CA,Z[BA++]=BA;F.push(new k2(Z,j[2]-CA,t)),z.push(CA-M)}}function B(M,x){return(F,z,j)=>{let X=0,eA=F.length-1,Z,CA;if(eA>=0&&(Z=F[eA])instanceof Pa){if(!eA&&Z.type==M&&Z.length==j)return Z;(CA=Z.prop(Hi.lookAhead))&&(X=z[eA]+Z.length+CA)}return E(M,F,z,j,X,x)}}function u(M,x,F,z,j,X,eA,Z,CA){let wA=[],BA=[];for(;M.length>z;)wA.push(M.pop()),BA.push(x.pop()+F-j);M.push(E(t.types[eA],wA,BA,X-j,Z-X,CA)),x.push(j-F)}function E(M,x,F,z,j,X,eA){if(X){let Z=[Hi.contextHash,X];eA=eA?[Z].concat(eA):[Z]}if(j>25){let Z=[Hi.lookAhead,j];eA=eA?[Z].concat(eA):[Z]}return new Pa(M,x,F,z,eA)}function f(M,x){let F=r.fork(),z=0,j=0,X=0,eA=F.end-n,Z={size:0,start:0,skip:0};A:for(let CA=F.pos-M;F.pos>CA;){let wA=F.size;if(F.id==x&&wA>=0){Z.size=z,Z.start=j,Z.skip=X,X+=4,z+=4,F.next();continue}let BA=F.pos-wA;if(wA<0||BA<CA||F.start<eA)break;let QA=F.id>=a?4:0,RA=F.start;for(F.next();F.pos>BA;){if(F.size<0)if(F.size==-3||F.size==-4)QA+=4;else break A;else F.id>=a&&(QA+=4);F.next()}j=RA,z+=wA,X+=QA}return(x<0||z==M)&&(Z.size=z,Z.start=j,Z.skip=X),Z.size>4?Z:void 0}function m(M,x,F){let{id:z,start:j,end:X,size:eA}=r;if(r.next(),eA>=0&&z<a){let Z=F;if(eA>4){let CA=r.pos-(eA-4);for(;r.pos>CA;)F=m(M,x,F)}x[--F]=Z,x[--F]=X-M,x[--F]=j-M,x[--F]=z}else eA==-3?l=z:eA==-4&&(g=z);return F}let v=[],S=[];for(;r.pos>0;)C(i.start||0,i.bufferStart||0,v,S,-1,0);let k=(e=i.length)!==null&&e!==void 0?e:v.length?S[0]+v[0].length:0;return new Pa(s[i.topID],v.reverse(),S.reverse(),k)}var zH=new WeakMap;function m8(i,e){if(!i.isAnonymous||e instanceof k2||e.type!=i)return 1;let A=zH.get(e);if(A==null){A=1;for(let t of e.children){if(t.type!=i||!(t instanceof Pa)){A=1;break}A+=m8(i,t)}zH.set(e,A)}return A}function kS(i,e,A,t,n,o,a,r,s){let l=0;for(let u=t;u<n;u++)l+=m8(i,e[u]);let g=Math.ceil(l*1.5/8),C=[],d=[];function B(u,E,f,m,v){for(let S=f;S<m;){let k=S,M=E[S],x=m8(i,u[S]);for(S++;S<m;S++){let F=m8(i,u[S]);if(x+F>=g)break;x+=F}if(S==k+1){if(x>g){let F=u[k];B(F.children,F.positions,0,F.children.length,E[k]+v);continue}C.push(u[k])}else{let F=E[S-1]+u[S-1].length-M;C.push(kS(i,u,E,k,S,M,F,null,s))}d.push(M+v-o)}}return B(e,A,t,n,0),(r||s)(C,d,a)}var Md=class i{constructor(e,A,t,n,o=!1,a=!1){this.from=e,this.to=A,this.tree=t,this.offset=n,this.open=(o?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,A=[],t=!1){let n=[new i(0,e.length,e,0,!1,t)];for(let o of A)o.to>e.length&&n.push(o);return n}static applyChanges(e,A,t=128){if(!A.length)return e;let n=[],o=1,a=e.length?e[0]:null;for(let r=0,s=0,l=0;;r++){let g=r<A.length?A[r]:null,C=g?g.fromA:1e9;if(C-s>=t)for(;a&&a.from<C;){let d=a;if(s>=d.from||C<=d.to||l){let B=Math.max(d.from,s)-l,u=Math.min(d.to,C)-l;d=B>=u?null:new i(B,u,d.tree,d.offset+l,r>0,!!g)}if(d&&n.push(d),a.to>C)break;a=o<e.length?e[o++]:null}if(!g)break;s=g.toA,l=g.toA-g.toB}return n}},Ch=class{startParse(e,A,t){return typeof e=="string"&&(e=new MS(e)),t=t?t.length?t.map(n=>new I4(n.from,n.to)):[new I4(0,0)]:[new I4(0,e.length)],this.createParse(e,A||[],t)}parse(e,A,t){let n=this.startParse(e,A,t);for(;;){let o=n.advance();if(o)return o}}},MS=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,A){return this.string.slice(e,A)}};var VAe=new Hi({perNode:!0});var Z0A=0,lc=class i{constructor(e,A,t,n){this.name=e,this.set=A,this.base=t,this.modified=n,this.id=Z0A++}toString(){let{name:e}=this;for(let A of this.modified)A.name&&(e=`${A.name}(${e})`);return e}static define(e,A){let t=typeof e=="string"?e:"?";if(e instanceof i&&(A=e),A?.base)throw new Error("Can not derive from a modified tag");let n=new i(t,[],null,[]);if(n.set.push(n),A)for(let o of A.set)n.set.push(o);return n}static defineModifier(e){let A=new b8(e);return t=>t.modified.indexOf(A)>-1?t:b8.get(t.base||t,t.modified.concat(A).sort((n,o)=>n.id-o.id))}},X0A=0,b8=class i{constructor(e){this.name=e,this.instances=[],this.id=X0A++}static get(e,A){if(!A.length)return e;let t=A[0].instances.find(r=>r.base==e&&$0A(A,r.modified));if(t)return t;let n=[],o=new lc(e.name,n,e,A);for(let r of A)r.instances.push(o);let a=ACA(A);for(let r of e.set)if(!r.modified.length)for(let s of a)n.push(i.get(r,s));return o}};function $0A(i,e){return i.length==e.length&&i.every((A,t)=>A==e[t])}function ACA(i){let e=[[]];for(let A=0;A<i.length;A++)for(let t=0,n=e.length;t<n;t++)e.push(e[t].concat(i[A]));return e.sort((A,t)=>t.length-A.length)}function M8(i){let e=Object.create(null);for(let A in i){let t=i[A];Array.isArray(t)||(t=[t]);for(let n of A.split(" "))if(n){let o=[],a=2,r=n;for(let C=0;;){if(r=="..."&&C>0&&C+3==n.length){a=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!d)throw new RangeError("Invalid path: "+n);if(o.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),C+=d[0].length,C==n.length)break;let B=n[C++];if(C==n.length&&B=="!"){a=0;break}if(B!="/")throw new RangeError("Invalid path: "+n);r=n.slice(C)}let s=o.length-1,l=o[s];if(!l)throw new RangeError("Invalid path: "+n);let g=new kd(t,a,s>0?o.slice(0,s):null);e[l]=g.sort(e[l])}}return WH.add(e)}var WH=new Hi({combine(i,e){let A,t,n;for(;i||e;){if(!i||e&&i.depth>=e.depth?(n=e,e=e.next):(n=i,i=i.next),A&&A.mode==n.mode&&!n.context&&!A.context)continue;let o=new kd(n.tags,n.mode,n.context);A?A.next=o:t=o,A=o}return t}}),kd=class{constructor(e,A,t,n){this.tags=e,this.mode=A,this.context=t,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};kd.empty=new kd([],2,null);function NS(i,e){let A=Object.create(null);for(let o of i)if(!Array.isArray(o.tag))A[o.tag.id]=o.class;else for(let a of o.tag)A[a.id]=o.class;let{scope:t,all:n=null}=e||{};return{style:o=>{let a=n;for(let r of o)for(let s of r.set){let l=A[s.id];if(l){a=a?a+" "+l:l;break}}return a},scope:t}}function eCA(i,e){let A=null;for(let t of i){let n=t.style(e);n&&(A=A?A+" "+n:n)}return A}function ZH(i,e,A,t=0,n=i.length){let o=new xS(t,Array.isArray(e)?e:[e],A);o.highlightRange(i.cursor(),t,n,"",o.highlighters),o.flush(n)}var xS=class{constructor(e,A,t){this.at=e,this.highlighters=A,this.span=t,this.class=""}startSpan(e,A){A!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=A)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,A,t,n,o){let{type:a,from:r,to:s}=e;if(r>=t||s<=A)return;a.isTop&&(o=this.highlighters.filter(B=>!B.scope||B.scope(a)));let l=n,g=tCA(e)||kd.empty,C=eCA(o,g.tags);if(C&&(l&&(l+=" "),l+=C,g.mode==1&&(n+=(n?" ":"")+C)),this.startSpan(Math.max(A,r),l),g.opaque)return;let d=e.tree&&e.tree.prop(Hi.mounted);if(d&&d.overlay){let B=e.node.enter(d.overlay[0].from+r,1),u=this.highlighters.filter(f=>!f.scope||f.scope(d.tree.type)),E=e.firstChild();for(let f=0,m=r;;f++){let v=f<d.overlay.length?d.overlay[f]:null,S=v?v.from+r:s,k=Math.max(A,m),M=Math.min(t,S);if(k<M&&E)for(;e.from<M&&(this.highlightRange(e,k,M,n,o),this.startSpan(Math.min(M,e.to),l),!(e.to>=S||!e.nextSibling())););if(!v||S>t)break;m=v.to+r,m>A&&(this.highlightRange(B.cursor(),Math.max(A,v.from+r),Math.min(t,m),"",u),this.startSpan(Math.min(t,m),l))}E&&e.parent()}else if(e.firstChild()){d&&(n="");do if(!(e.to<=A)){if(e.from>=t)break;this.highlightRange(e,A,t,n,o),this.startSpan(Math.min(t,e.to),l)}while(e.nextSibling());e.parent()}}};function tCA(i){let e=i.type.prop(WH);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var tt=lc.define,y8=tt(),_2=tt(),VH=tt(_2),qH=tt(_2),x2=tt(),D8=tt(x2),_S=tt(x2),h0=tt(),Sd=tt(h0),I0=tt(),B0=tt(),RS=tt(),u4=tt(RS),v8=tt(),Oe={comment:y8,lineComment:tt(y8),blockComment:tt(y8),docComment:tt(y8),name:_2,variableName:tt(_2),typeName:VH,tagName:tt(VH),propertyName:qH,attributeName:tt(qH),className:tt(_2),labelName:tt(_2),namespace:tt(_2),macroName:tt(_2),literal:x2,string:D8,docString:tt(D8),character:tt(D8),attributeValue:tt(D8),number:_S,integer:tt(_S),float:tt(_S),bool:tt(x2),regexp:tt(x2),escape:tt(x2),color:tt(x2),url:tt(x2),keyword:I0,self:tt(I0),null:tt(I0),atom:tt(I0),unit:tt(I0),modifier:tt(I0),operatorKeyword:tt(I0),controlKeyword:tt(I0),definitionKeyword:tt(I0),moduleKeyword:tt(I0),operator:B0,derefOperator:tt(B0),arithmeticOperator:tt(B0),logicOperator:tt(B0),bitwiseOperator:tt(B0),compareOperator:tt(B0),updateOperator:tt(B0),definitionOperator:tt(B0),typeOperator:tt(B0),controlOperator:tt(B0),punctuation:RS,separator:tt(RS),bracket:u4,angleBracket:tt(u4),squareBracket:tt(u4),paren:tt(u4),brace:tt(u4),content:h0,heading:Sd,heading1:tt(Sd),heading2:tt(Sd),heading3:tt(Sd),heading4:tt(Sd),heading5:tt(Sd),heading6:tt(Sd),contentSeparator:tt(h0),list:tt(h0),quote:tt(h0),emphasis:tt(h0),strong:tt(h0),link:tt(h0),monospace:tt(h0),strikethrough:tt(h0),inserted:tt(),deleted:tt(),changed:tt(),invalid:tt(),meta:v8,documentMeta:tt(v8),annotation:tt(v8),processingInstruction:tt(v8),definition:lc.defineModifier("definition"),constant:lc.defineModifier("constant"),function:lc.defineModifier("function"),standard:lc.defineModifier("standard"),local:lc.defineModifier("local"),special:lc.defineModifier("special")};for(let i in Oe){let e=Oe[i];e instanceof lc&&(e.name=i)}var ZAe=NS([{tag:Oe.link,class:"tok-link"},{tag:Oe.heading,class:"tok-heading"},{tag:Oe.emphasis,class:"tok-emphasis"},{tag:Oe.strong,class:"tok-strong"},{tag:Oe.keyword,class:"tok-keyword"},{tag:Oe.atom,class:"tok-atom"},{tag:Oe.bool,class:"tok-bool"},{tag:Oe.url,class:"tok-url"},{tag:Oe.labelName,class:"tok-labelName"},{tag:Oe.inserted,class:"tok-inserted"},{tag:Oe.deleted,class:"tok-deleted"},{tag:Oe.literal,class:"tok-literal"},{tag:Oe.string,class:"tok-string"},{tag:Oe.number,class:"tok-number"},{tag:[Oe.regexp,Oe.escape,Oe.special(Oe.string)],class:"tok-string2"},{tag:Oe.variableName,class:"tok-variableName"},{tag:Oe.local(Oe.variableName),class:"tok-variableName tok-local"},{tag:Oe.definition(Oe.variableName),class:"tok-variableName tok-definition"},{tag:Oe.special(Oe.variableName),class:"tok-variableName2"},{tag:Oe.definition(Oe.propertyName),class:"tok-propertyName tok-definition"},{tag:Oe.typeName,class:"tok-typeName"},{tag:Oe.namespace,class:"tok-namespace"},{tag:Oe.className,class:"tok-className"},{tag:Oe.macroName,class:"tok-macroName"},{tag:Oe.propertyName,class:"tok-propertyName"},{tag:Oe.operator,class:"tok-operator"},{tag:Oe.comment,class:"tok-comment"},{tag:Oe.meta,class:"tok-meta"},{tag:Oe.invalid,class:"tok-invalid"},{tag:Oe.punctuation,class:"tok-punctuation"}]);var FS,dh=new Hi;function iCA(i){return nt.define({combine:i?e=>e.concat(i):void 0})}var nCA=new Hi,gc=(()=>{class i{constructor(A,t,n=[],o=""){this.data=A,this.name=o,ir.prototype.hasOwnProperty("tree")||Object.defineProperty(ir.prototype,"tree",{get(){return Kr(this)}}),this.parser=t,this.extension=[R2.of(this),ir.languageData.of((a,r,s)=>{let l=XH(a,r,s),g=l.type.prop(dh);if(!g)return[];let C=a.facet(g),d=l.type.prop(nCA);if(d){let B=l.resolve(r-l.from,s);for(let u of d)if(u.test(B,a)){let E=a.facet(u.facet);return u.type=="replace"?E:E.concat(C)}}return C})].concat(n)}isActiveAt(A,t,n=-1){return XH(A,t,n).type.prop(dh)==this.data}findRegions(A){let t=A.facet(R2);if(t?.data==this.data)return[{from:0,to:A.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],o=(a,r)=>{if(a.prop(dh)==this.data){n.push({from:r,to:r+a.length});return}let s=a.prop(Hi.mounted);if(s){if(s.tree.prop(dh)==this.data){if(s.overlay)for(let l of s.overlay)n.push({from:l.from+r,to:l.to+r});else n.push({from:r,to:r+a.length});return}else if(s.overlay){let l=n.length;if(o(s.tree,s.overlay[0].from+r),n.length>l)return}}for(let l=0;l<a.children.length;l++){let g=a.children[l];g instanceof Pa&&o(g,a.positions[l]+r)}};return o(Kr(A),0),n}get allowsNesting(){return!0}}return i.setState=ln.define(),i})();function XH(i,e,A){let t=i.facet(R2),n=Kr(i).topNode;if(!t||t.allowsNesting)for(let o=n;o;o=o.enter(e,A,Ga.ExcludeBuffers|Ga.EnterBracketed))o.type.isTop&&(n=o);return n}var S8=class i extends gc{constructor(e,A,t){super(e,A,[],t),this.parser=A}static define(e){let A=iCA(e.languageData);return new i(A,e.parser.configure({props:[dh.add(t=>t.isTop?A:void 0)]}),e.name)}configure(e,A){return new i(this.data,this.parser.configure(e),A||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Kr(i){let e=i.field(gc.state,!1);return e?e.tree:Pa.empty}function jS(i,e,A=50){var t;let n=(t=i.field(gc.state,!1))===null||t===void 0?void 0:t.context;if(!n)return null;let o=n.viewport;n.updateViewport({from:0,to:e});let a=n.isDone(e)||n.work(A,e)?n.tree:null;return n.updateViewport(o),a}var US=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,A){let t=this.cursorPos-this.string.length;return e<t||A>=this.cursorPos?this.doc.sliceString(e,A):this.string.slice(e-t,A-t)}},p4=null,TS=class i{constructor(e,A,t=[],n,o,a,r,s){this.parser=e,this.state=A,this.fragments=t,this.tree=n,this.treeLen=o,this.viewport=a,this.skipped=r,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(e,A,t){return new i(e,A,[],Pa.empty,0,t,[],null)}startParse(){return this.parser.startParse(new US(this.state.doc),this.fragments)}work(e,A){return A!=null&&A>=this.state.doc.length&&(A=void 0),this.tree!=Pa.empty&&this.isDone(A??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var t;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),A!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>A)&&A<this.state.doc.length&&this.parse.stopAt(A);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Md.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(t=this.parse.stoppedAt)!==null&&t!==void 0?t:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(A??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,A;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(A=this.parse.advance()););}),this.treeLen=e,this.tree=A,this.fragments=this.withoutTempSkipped(Md.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let A=p4;p4=this;try{return e()}finally{p4=A}}withoutTempSkipped(e){for(let A;A=this.tempSkipped.pop();)e=$H(e,A.from,A.to);return e}changes(e,A){let{fragments:t,tree:n,treeLen:o,viewport:a,skipped:r}=this;if(this.takeTree(),!e.empty){let s=[];if(e.iterChangedRanges((l,g,C,d)=>s.push({fromA:l,toA:g,fromB:C,toB:d})),t=Md.applyChanges(t,s),n=Pa.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){r=[];for(let l of this.skipped){let g=e.mapPos(l.from,1),C=e.mapPos(l.to,-1);g<C&&r.push({from:g,to:C})}}}return new i(this.parser,A,t,n,o,a,r,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let A=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:o}=this.skipped[t];n<e.to&&o>e.from&&(this.fragments=$H(this.fragments,n,o),this.skipped.splice(t--,1))}return this.skipped.length>=A?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,A){this.skipped.push({from:e,to:A})}static getSkippingParser(e){return new class extends Ch{createParse(A,t,n){let o=n[0].from,a=n[n.length-1].to;return{parsedPos:o,advance(){let s=p4;if(s){for(let l of n)s.tempSkipped.push(l);e&&(s.scheduleOn=s.scheduleOn?Promise.all([s.scheduleOn,e]):e)}return this.parsedPos=a,new Pa(ys.none,[],[],a-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let A=this.fragments;return this.treeLen>=e&&A.length&&A[0].from==0&&A[0].to>=e}static get(){return p4}};function $H(i,e,A){return Md.applyChanges(i,[{fromA:e,toA:A,fromB:e,toB:A}])}var m4=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let A=this.context.changes(e.changes,e.state),t=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),A.viewport.to);return A.work(20,t)||A.takeTree(),new i(A)}static init(e){let A=Math.min(3e3,e.doc.length),t=TS.create(e.facet(R2).parser,e,{from:0,to:A});return t.work(20,A)||t.takeTree(),new i(t)}};gc.state=La.define({create:m4.init,update(i,e){for(let A of e.effects)if(A.is(gc.setState))return A.value;return e.startState.facet(R2)!=e.state.facet(R2)?m4.init(e.state):i.apply(e)}});var az=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(az=i=>{let e=-1,A=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(A):cancelIdleCallback(e)});var LS=typeof navigator<"u"&&(!((FS=navigator.scheduling)===null||FS===void 0)&&FS.isInputPending)?()=>navigator.scheduling.isInputPending():null,oCA=Po.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let A=this.view.state.field(gc.state).context;(A.updateViewport(e.view.viewport)||this.view.viewport.to>A.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(A)}scheduleWork(){if(this.working)return;let{state:e}=this.view,A=e.field(gc.state);(A.tree!=A.context.tree||!A.context.isDone(e.doc.length))&&(this.working=az(this.work))}work(e){this.working=null;let A=Date.now();if(this.chunkEnd<A&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=A+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:t,viewport:{to:n}}=this.view,o=t.field(gc.state);if(o.tree==o.context.tree&&o.context.isDone(n+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!LS?Math.max(25,e.timeRemaining()-5):1e9),r=o.context.treeLen<n&&t.doc.length>n+1e3,s=o.context.work(()=>LS&&LS()||Date.now()>a,n+(r?0:1e5));this.chunkBudget-=Date.now()-A,(s||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:gc.setState.of(new m4(o.context))})),this.chunkBudget>0&&!(s&&!r)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(A=>Gr(this.view.state,A)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),R2=nt.define({combine(i){return i.length?i[0]:null},enables:i=>[gc.state,oCA,ui.contentAttributes.compute([i],e=>{let A=e.facet(i);return A&&A.name?{"data-language":A.name}:{}})]}),k8=class{constructor(e,A=[]){this.language=e,this.support=A,this.extension=[e,A]}};var aCA=nt.define(),Rd=nt.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(A=>A!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Cc(i){let e=i.facet(Rd);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function hh(i,e){let A="",t=i.tabSize,n=i.facet(Rd)[0];if(n==" "){for(;e>=t;)A+=" ",e-=t;n=" "}for(let o=0;o<e;o++)A+=n;return A}function x8(i,e){i instanceof ir&&(i=new _d(i));for(let t of i.state.facet(aCA)){let n=t(i,e);if(n!==void 0)return n}let A=Kr(i.state);return A.length>=e?rCA(i,A,e):null}var _d=class{constructor(e,A={}){this.state=e,this.options=A,this.unit=Cc(e)}lineAt(e,A=1){let t=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:o}=this.options;return n!=null&&n>=t.from&&n<=t.to?o&&n==e?{text:"",from:e}:(A<0?n<e:n<=e)?{text:t.text.slice(n-t.from),from:n}:{text:t.text.slice(0,n-t.from),from:t.from}:t}textAfterPos(e,A=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:t,from:n}=this.lineAt(e,A);return t.slice(e-n,Math.min(t.length,e+100-n))}column(e,A=1){let{text:t,from:n}=this.lineAt(e,A),o=this.countColumn(t,e-n),a=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return a>-1&&(o+=a-this.countColumn(t,t.search(/\S|$/))),o}countColumn(e,A=e.length){return rC(e,this.state.tabSize,A)}lineIndent(e,A=1){let{text:t,from:n}=this.lineAt(e,A),o=this.options.overrideIndentation;if(o){let a=o(n);if(a>-1)return a}return this.countColumn(t,t.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},VS=new Hi;function rCA(i,e,A){let t=e.resolveStack(A),n=e.resolveInner(A,-1).resolve(A,0).enterUnfinishedNodesBefore(A);if(n!=t.node){let o=[];for(let a=n;a&&!(a.from<t.node.from||a.to>t.node.to||a.from==t.node.from&&a.type==t.node.type);a=a.parent)o.push(a);for(let a=o.length-1;a>=0;a--)t={node:o[a],next:t}}return rz(t,i,A)}function rz(i,e,A){for(let t=i;t;t=t.next){let n=lCA(t.node);if(n)return n(OS.create(e,A,t))}return 0}function sCA(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function lCA(i){let e=i.type.prop(VS);if(e)return e;let A=i.firstChild,t;if(A&&(t=A.type.prop(Hi.closedBy))){let n=i.lastChild,o=n&&t.indexOf(n.name)>-1;return a=>dCA(a,!0,1,void 0,o&&!sCA(a)?n.from:void 0)}return i.parent==null?gCA:null}function gCA(){return 0}var OS=class i extends _d{constructor(e,A,t){super(e.state,e.options),this.base=e,this.pos=A,this.context=t}get node(){return this.context.node}static create(e,A,t){return new i(e,A,t)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let A=this.state.doc.lineAt(e.from);for(;;){let t=e.resolve(A.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(cCA(t,e))break;A=this.state.doc.lineAt(t.from)}return this.lineIndent(A.from)}continue(){return rz(this.context.next,this.base,this.pos)}};function cCA(i,e){for(let A=e;A;A=A.parent)if(i==A)return!0;return!1}function CCA(i){let e=i.node,A=e.childAfter(e.from),t=e.lastChild;if(!A)return null;let n=i.options.simulateBreak,o=i.state.doc.lineAt(A.from),a=n==null||n<=o.from?o.to:Math.min(o.to,n);for(let r=A.to;;){let s=e.childAfter(r);if(!s||s==t)return null;if(!s.type.isSkipped){if(s.from>=a)return null;let l=/^ */.exec(o.text.slice(A.to-o.from))[0].length;return{from:A.from,to:A.to+l}}r=s.to}}function dCA(i,e,A,t,n){let o=i.textAfter,a=o.match(/^\s*/)[0].length,r=t&&o.slice(a,a+t.length)==t||n==i.pos+a,s=e?CCA(i):null;return s?r?i.column(s.from):i.column(s.to):i.baseIndent+(r?0:i.unit*A)}function qS({except:i,units:e=1}={}){return A=>{let t=i&&i.test(A.textAfter);return A.baseIndent+(t?0:e*A.unit)}}var ICA=200;function sz(){return ir.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let A=i.newDoc,{head:t}=i.newSelection.main,n=A.lineAt(t);if(t>n.from+ICA)return i;let o=A.sliceString(n.from,t);if(!e.some(l=>l.test(o)))return i;let{state:a}=i,r=-1,s=[];for(let{head:l}of a.selection.ranges){let g=a.doc.lineAt(l);if(g.from==r)continue;r=g.from;let C=x8(a,g.from);if(C==null)continue;let d=/^\s*/.exec(g.text)[0],B=hh(a,C);d!=B&&s.push({from:g.from,to:g.from+d.length,insert:B})}return s.length?[i,{changes:s,sequential:!0}]:i})}var WS=nt.define(),w4=new Hi;function lz(i){let e=i.firstChild,A=i.lastChild;return e&&e.to<A.from?{from:e.to,to:A.type.isError?i.to:A.from}:null}function BCA(i,e,A){let t=Kr(i);if(t.length<A)return null;let n=t.resolveStack(A,1),o=null;for(let a=n;a;a=a.next){let r=a.node;if(r.to<=A||r.from>A)continue;if(o&&r.from<e)break;let s=r.type.prop(w4);if(s&&(r.to<t.length-50||t.length==i.doc.length||!hCA(r))){let l=s(r,i);l&&l.from<=A&&l.from>=e&&l.to>A&&(o=l)}}return o}function hCA(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ih(i,e,A){for(let t of i.facet(WS)){let n=t(i,e,A);if(n)return n}return BCA(i,e,A)}function gz(i,e){let A=e.mapPos(i.from,1),t=e.mapPos(i.to,-1);return A>=t?void 0:{from:A,to:t}}var Eh=ln.define({map:gz}),y4=ln.define({map:gz});function cz(i){let e=[];for(let{head:A}of i.state.selection.ranges)e.some(t=>t.from<=A&&t.to>=A)||e.push(i.lineBlockAt(A));return e}var xd=La.define({create(){return Lt.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((A,t)=>i=Az(i,A,t)),i=i.map(e.changes);for(let A of e.effects)if(A.is(Eh)&&!ECA(i,A.value.from,A.value.to)){let{preparePlaceholder:t}=e.state.facet($S),n=t?Lt.replace({widget:new JS(t(e.state,A.value))}):ez;i=i.update({add:[n.range(A.value.from,A.value.to)]})}else A.is(y4)&&(i=i.update({filter:(t,n)=>A.value.from!=t||A.value.to!=n,filterFrom:A.value.from,filterTo:A.value.to}));return e.selection&&(i=Az(i,e.selection.main.head)),i},provide:i=>ui.decorations.from(i),toJSON(i,e){let A=[];return i.between(0,e.doc.length,(t,n)=>{A.push(t,n)}),A},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let A=0;A<i.length;){let t=i[A++],n=i[A++];if(typeof t!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(ez.range(t,n))}return Lt.set(e,!0)}});function Az(i,e,A=e){let t=!1;return i.between(e,A,(n,o)=>{n<A&&o>e&&(t=!0)}),t?i.update({filterFrom:e,filterTo:A,filter:(n,o)=>n>=A||o<=e}):i}function _8(i,e,A){var t;let n=null;return(t=i.field(xd,!1))===null||t===void 0||t.between(e,A,(o,a)=>{(!n||n.from>o)&&(n={from:o,to:a})}),n}function ECA(i,e,A){let t=!1;return i.between(e,e,(n,o)=>{n==e&&o==A&&(t=!0)}),t}function Cz(i,e){return i.field(xd,!1)?e:e.concat(ln.appendConfig.of(Bz()))}var QCA=i=>{for(let e of cz(i)){let A=Ih(i.state,e.from,e.to);if(A)return i.dispatch({effects:Cz(i.state,[Eh.of(A),dz(i,A)])}),!0}return!1},ZS=i=>{if(!i.state.field(xd,!1))return!1;let e=[];for(let A of cz(i)){let t=_8(i.state,A.from,A.to);t&&e.push(y4.of(t),dz(i,t,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function dz(i,e,A=!0){let t=i.state.doc.lineAt(e.from).number,n=i.state.doc.lineAt(e.to).number;return ui.announce.of(`${i.state.phrase(A?"Folded lines":"Unfolded lines")} ${t} ${i.state.phrase("to")} ${n}.`)}var uCA=i=>{let{state:e}=i,A=[];for(let t=0;t<e.doc.length;){let n=i.lineBlockAt(t),o=Ih(e,n.from,n.to);o&&A.push(Eh.of(o)),t=(o?i.lineBlockAt(o.to):n).to+1}return A.length&&i.dispatch({effects:Cz(i.state,A)}),!!A.length},XS=i=>{let e=i.state.field(xd,!1);if(!e||!e.size)return!1;let A=[];return e.between(0,i.state.doc.length,(t,n)=>{A.push(y4.of({from:t,to:n}))}),i.dispatch({effects:A}),!0};var Iz=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:QCA},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ZS},{key:"Ctrl-Alt-[",run:uCA},{key:"Ctrl-Alt-]",run:XS}],pCA={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},$S=nt.define({combine(i){return Lr(i,pCA)}});function Bz(i){let e=[xd,mCA];return i&&e.push($S.of(i)),e}function hz(i,e){let{state:A}=i,t=A.facet($S),n=a=>{let r=i.lineBlockAt(i.posAtDOM(a.target)),s=_8(i.state,r.from,r.to);s&&i.dispatch({effects:y4.of(s)}),a.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(i,n,e);let o=document.createElement("span");return o.textContent=t.placeholderText,o.setAttribute("aria-label",A.phrase("folded code")),o.title=A.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=n,o}var ez=Lt.replace({widget:new class extends gl{toDOM(i){return hz(i,null)}}}),JS=class extends gl{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return hz(e,this.value)}},fCA={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},f4=class extends Cl{constructor(e,A){super(),this.config=e,this.open=A}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let A=document.createElement("span");return A.textContent=this.open?this.config.openText:this.config.closedText,A.title=e.state.phrase(this.open?"Fold line":"Unfold line"),A}};function Ez(i={}){let e=P(P({},fCA),i),A=new f4(e,!0),t=new f4(e,!1),n=Po.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(R2)!=a.state.facet(R2)||a.startState.field(xd,!1)!=a.state.field(xd,!1)||Kr(a.startState)!=Kr(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let r=new Xr;for(let s of a.viewportLineBlocks){let l=_8(a.state,s.from,s.to)?t:Ih(a.state,s.from,s.to)?A:null;l&&r.add(s.from,s.from,l)}return r.finish()}}),{domEventHandlers:o}=e;return[n,p8({class:"cm-foldGutter",markers(a){var r;return((r=a.plugin(n))===null||r===void 0?void 0:r.markers)||uo.empty},initialSpacer(){return new f4(e,!1)},domEventHandlers:$A(P({},o),{click:(a,r,s)=>{if(o.click&&o.click(a,r,s))return!0;let l=_8(a.state,r.from,r.to);if(l)return a.dispatch({effects:y4.of(l)}),!0;let g=Ih(a.state,r.from,r.to);return g?(a.dispatch({effects:Eh.of(g)}),!0):!1}})}),Bz()]}var mCA=ui.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Bh=class i{constructor(e,A){this.specs=e;let t;function n(r){let s=Cg.newName();return(t||(t=Object.create(null)))["."+s]=r,s}let o=typeof A.all=="string"?A.all:A.all?n(A.all):void 0,a=A.scope;this.scope=a instanceof gc?r=>r.prop(dh)==a.data:a?r=>r==a:void 0,this.style=NS(e.map(r=>({tag:r.tag,class:r.class||n(Object.assign({},r,{tag:null}))})),{all:o}).style,this.module=t?new Cg(t):null,this.themeType=A.themeType}static define(e,A){return new i(e,A||{})}},YS=nt.define(),Qz=nt.define({combine(i){return i.length?[i[0]]:null}});function GS(i){let e=i.facet(YS);return e.length?e:i.facet(Qz)}function Ak(i,e){let A=[wCA],t;return i instanceof Bh&&(i.module&&A.push(ui.styleModule.of(i.module)),t=i.themeType),e?.fallback?A.push(Qz.of(i)):t?A.push(YS.computeN([ui.darkTheme],n=>n.facet(ui.darkTheme)==(t=="dark")?[i]:[])):A.push(YS.of(i)),A}var HS=class{constructor(e){this.markCache=Object.create(null),this.tree=Kr(e.state),this.decorations=this.buildDeco(e,GS(e.state)),this.decoratedTo=e.viewport.to}update(e){let A=Kr(e.state),t=GS(e.state),n=t!=GS(e.startState),{viewport:o}=e.view,a=e.changes.mapPos(this.decoratedTo,1);A.length<o.to&&!n&&A.type==this.tree.type&&a>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(A!=this.tree||e.viewportChanged||n)&&(this.tree=A,this.decorations=this.buildDeco(e.view,t),this.decoratedTo=o.to)}buildDeco(e,A){if(!A||!this.tree.length)return Lt.none;let t=new Xr;for(let{from:n,to:o}of e.visibleRanges)ZH(this.tree,A,(a,r,s)=>{t.add(a,r,this.markCache[s]||(this.markCache[s]=Lt.mark({class:s})))},n,o);return t.finish()}},wCA=oc.high(Po.fromClass(HS,{decorations:i=>i.decorations})),uz=Bh.define([{tag:Oe.meta,color:"#404740"},{tag:Oe.link,textDecoration:"underline"},{tag:Oe.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Oe.emphasis,fontStyle:"italic"},{tag:Oe.strong,fontWeight:"bold"},{tag:Oe.strikethrough,textDecoration:"line-through"},{tag:Oe.keyword,color:"#708"},{tag:[Oe.atom,Oe.bool,Oe.url,Oe.contentSeparator,Oe.labelName],color:"#219"},{tag:[Oe.literal,Oe.inserted],color:"#164"},{tag:[Oe.string,Oe.deleted],color:"#a11"},{tag:[Oe.regexp,Oe.escape,Oe.special(Oe.string)],color:"#e40"},{tag:Oe.definition(Oe.variableName),color:"#00f"},{tag:Oe.local(Oe.variableName),color:"#30a"},{tag:[Oe.typeName,Oe.namespace],color:"#085"},{tag:Oe.className,color:"#167"},{tag:[Oe.special(Oe.variableName),Oe.macroName],color:"#256"},{tag:Oe.definition(Oe.propertyName),color:"#00c"},{tag:Oe.comment,color:"#940"},{tag:Oe.invalid,color:"#f00"}]),yCA=ui.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),pz=1e4,fz="()[]{}",mz=nt.define({combine(i){return Lr(i,{afterCursor:!0,brackets:fz,maxScanDistance:pz,renderMatch:bCA})}}),DCA=Lt.mark({class:"cm-matchingBracket"}),vCA=Lt.mark({class:"cm-nonmatchingBracket"});function bCA(i){let e=[],A=i.matched?DCA:vCA;return e.push(A.range(i.start.from,i.start.to)),i.end&&e.push(A.range(i.end.from,i.end.to)),e}function tz(i){let e=[],A=i.facet(mz);for(let t of i.selection.ranges){if(!t.empty)continue;let n=cc(i,t.head,-1,A)||t.head>0&&cc(i,t.head-1,1,A)||A.afterCursor&&(cc(i,t.head,1,A)||t.head<i.doc.length&&cc(i,t.head+1,-1,A));n&&(e=e.concat(A.renderMatch(n,i)))}return Lt.set(e,!0)}var MCA=Po.fromClass(class{constructor(i){this.paused=!1,this.decorations=tz(i.state)}update(i){(i.docChanged||i.selectionSet||this.paused)&&(i.view.composing?(this.decorations=this.decorations.map(i.changes),this.paused=!0):(this.decorations=tz(i.state),this.paused=!1))}},{decorations:i=>i.decorations}),SCA=[MCA,yCA];function wz(i={}){return[mz.of(i),SCA]}var kCA=new Hi;function zS(i,e,A){let t=i.prop(e<0?Hi.openedBy:Hi.closedBy);if(t)return t;if(i.name.length==1){let n=A.indexOf(i.name);if(n>-1&&n%2==(e<0?1:0))return[A[n+e]]}return null}function PS(i){let e=i.type.prop(kCA);return e?e(i.node):i}function cc(i,e,A,t={}){let n=t.maxScanDistance||pz,o=t.brackets||fz,a=Kr(i),r=a.resolveInner(e,A);for(let s=r;s;s=s.parent){let l=zS(s.type,A,o);if(l&&s.from<s.to){let g=PS(s);if(g&&(A>0?e>=g.from&&e<g.to:e>g.from&&e<=g.to))return _CA(i,e,A,s,g,l,o)}}return xCA(i,e,A,a,r.type,n,o)}function _CA(i,e,A,t,n,o,a){let r=t.parent,s={from:n.from,to:n.to},l=0,g=r?.cursor();if(g&&(A<0?g.childBefore(t.from):g.childAfter(t.to)))do if(A<0?g.to<=t.from:g.from>=t.to){if(l==0&&o.indexOf(g.type.name)>-1&&g.from<g.to){let C=PS(g);return{start:s,end:C?{from:C.from,to:C.to}:void 0,matched:!0}}else if(zS(g.type,A,a))l++;else if(zS(g.type,-A,a)){if(l==0){let C=PS(g);return{start:s,end:C&&C.from<C.to?{from:C.from,to:C.to}:void 0,matched:!1}}l--}}while(A<0?g.prevSibling():g.nextSibling());return{start:s,matched:!1}}function xCA(i,e,A,t,n,o,a){let r=A<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),s=a.indexOf(r);if(s<0||s%2==0!=A>0)return null;let l={from:A<0?e-1:e,to:A>0?e+1:e},g=i.doc.iterRange(e,A>0?i.doc.length:0),C=0;for(let d=0;!g.next().done&&d<=o;){let B=g.value;A<0&&(d+=B.length);let u=e+d*A;for(let E=A>0?0:B.length-1,f=A>0?B.length:-1;E!=f;E+=A){let m=a.indexOf(B[E]);if(!(m<0||t.resolveInner(u+E,1).type!=n))if(m%2==0==A>0)C++;else{if(C==1)return{start:l,end:{from:u+E,to:u+E+1},matched:m>>1==s>>1};C--}}A>0&&(d+=B.length)}return g.done?{start:l,matched:!1}:null}var RCA=Object.create(null),iz=[ys.none];var nz=[],oz=Object.create(null),NCA=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"]])NCA[i]=FCA(RCA,e);function KS(i,e){nz.indexOf(i)>-1||(nz.push(i),console.warn(e))}function FCA(i,e){let A=[];for(let r of e.split(" ")){let s=[];for(let l of r.split(".")){let g=i[l]||Oe[l];g?typeof g=="function"?s.length?s=s.map(g):KS(l,`Modifier ${l} used at start of tag`):s.length?KS(l,`Tag ${l} used as modifier`):s=Array.isArray(g)?g:[g]:KS(l,`Unknown highlighting tag ${l}`)}for(let l of s)A.push(l)}if(!A.length)return 0;let t=e.replace(/ /g,"_"),n=t+" "+A.map(r=>r.id),o=oz[n];if(o)return o.id;let a=oz[n]=ys.define({id:iz.length,name:t,props:[M8({[t]:A})]});return iz.push(a),a.id}var oee={rtl:Lt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Lo.RTL}),ltr:Lt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Lo.LTR}),auto:Lt.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var LCA=i=>{let{state:e}=i,A=e.doc.lineAt(e.selection.main.from),t=nk(i.state,A.from);return t.line?GCA(i):t.block?UCA(i):!1};function ik(i,e){return({state:A,dispatch:t})=>{if(A.readOnly)return!1;let n=i(e,A);return n?(t(A.update(n)),!0):!1}}var GCA=ik(JCA,0);var KCA=ik(xz,0);var UCA=ik((i,e)=>xz(i,e,OCA(e)),0);function nk(i,e){let A=i.languageDataAt("commentTokens",e,1);return A.length?A[0]:{}}var D4=50;function TCA(i,{open:e,close:A},t,n){let o=i.sliceDoc(t-D4,t),a=i.sliceDoc(n,n+D4),r=/\s*$/.exec(o)[0].length,s=/^\s*/.exec(a)[0].length,l=o.length-r;if(o.slice(l-e.length,l)==e&&a.slice(s,s+A.length)==A)return{open:{pos:t-r,margin:r&&1},close:{pos:n+s,margin:s&&1}};let g,C;n-t<=2*D4?g=C=i.sliceDoc(t,n):(g=i.sliceDoc(t,t+D4),C=i.sliceDoc(n-D4,n));let d=/^\s*/.exec(g)[0].length,B=/\s*$/.exec(C)[0].length,u=C.length-B-A.length;return g.slice(d,d+e.length)==e&&C.slice(u,u+A.length)==A?{open:{pos:t+d+e.length,margin:/\s/.test(g.charAt(d+e.length))?1:0},close:{pos:n-B-A.length,margin:/\s/.test(C.charAt(u-1))?1:0}}:null}function OCA(i){let e=[];for(let A of i.selection.ranges){let t=i.doc.lineAt(A.from),n=A.to<=t.to?t:i.doc.lineAt(A.to);n.from>t.from&&n.from==A.to&&(n=A.to==t.to+1?t:i.doc.lineAt(A.to-1));let o=e.length-1;o>=0&&e[o].to>t.from?e[o].to=n.to:e.push({from:t.from+/^\s*/.exec(t.text)[0].length,to:n.to})}return e}function xz(i,e,A=e.selection.ranges){let t=A.map(o=>nk(e,o.from).block);if(!t.every(o=>o))return null;let n=A.map((o,a)=>TCA(e,t[a],o.from,o.to));if(i!=2&&!n.every(o=>o))return{changes:e.changes(A.map((o,a)=>n[a]?[]:[{from:o.from,insert:t[a].open+" "},{from:o.to,insert:" "+t[a].close}]))};if(i!=1&&n.some(o=>o)){let o=[];for(let a=0,r;a<n.length;a++)if(r=n[a]){let s=t[a],{open:l,close:g}=r;o.push({from:l.pos-s.open.length,to:l.pos+l.margin},{from:g.pos-g.margin,to:g.pos+s.close.length})}return{changes:o}}return null}function JCA(i,e,A=e.selection.ranges){let t=[],n=-1;A:for(let{from:o,to:a}of A){let r=t.length,s=1e9,l;for(let g=o;g<=a;){let C=e.doc.lineAt(g);if(l==null&&(l=nk(e,C.from).line,!l))continue A;if(C.from>n&&(o==a||a>C.from)){n=C.from;let d=/^\s*/.exec(C.text)[0].length,B=d==C.length,u=C.text.slice(d,d+l.length)==l?d:-1;d<C.text.length&&d<s&&(s=d),t.push({line:C,comment:u,token:l,indent:d,empty:B,single:!1})}g=C.to+1}if(s<1e9)for(let g=r;g<t.length;g++)t[g].indent<t[g].line.text.length&&(t[g].indent=s);t.length==r+1&&(t[r].single=!0)}if(i!=2&&t.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:r,token:s,indent:l,empty:g,single:C}of t)(C||!g)&&o.push({from:r.from+l,insert:s+" "});let a=e.changes(o);return{changes:a,selection:e.selection.map(a,1)}}else if(i!=1&&t.some(o=>o.comment>=0)){let o=[];for(let{line:a,comment:r,token:s}of t)if(r>=0){let l=a.from+r,g=l+s.length;a.text[g-a.from]==" "&&g++,o.push({from:l,to:g})}return{changes:o}}return null}function Qh(i,e){return Be.create(i.ranges.map(e),i.mainIndex)}function dc(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ic({state:i,dispatch:e},A){let t=Qh(i.selection,A);return t.eq(i.selection,!0)?!1:(e(dc(i,t)),!0)}function N8(i,e){return Be.cursor(e?i.to:i.from)}function Rz(i,e){return Ic(i,A=>A.empty?i.moveByChar(A,e):N8(A,e))}function Ds(i){return i.textDirectionAt(i.state.selection.main.head)==Lo.LTR}var Nz=i=>Rz(i,!Ds(i)),Fz=i=>Rz(i,Ds(i));function Lz(i,e){return Ic(i,A=>A.empty?i.moveByGroup(A,e):N8(A,e))}var YCA=i=>Lz(i,!Ds(i)),HCA=i=>Lz(i,Ds(i));var hee=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function zCA(i,e,A){if(e.type.prop(A))return!0;let t=e.to-e.from;return t&&(t>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function F8(i,e,A){let t=Kr(i).resolveInner(e.head),n=A?Hi.closedBy:Hi.openedBy;for(let s=e.head;;){let l=A?t.childAfter(s):t.childBefore(s);if(!l)break;zCA(i,l,n)?t=l:s=A?l.to:l.from}let o=t.type.prop(n),a,r;return o&&(a=A?cc(i,t.from,1):cc(i,t.to,-1))&&a.matched?r=A?a.end.to:a.end.from:r=A?t.to:t.from,Be.cursor(r,A?-1:1)}var PCA=i=>Ic(i,e=>F8(i.state,e,!Ds(i))),jCA=i=>Ic(i,e=>F8(i.state,e,Ds(i)));function Gz(i,e){return Ic(i,A=>{if(!A.empty)return N8(A,e);let t=i.moveVertically(A,e);return t.head!=A.head?t:i.moveToLineBoundary(A,e)})}var Kz=i=>Gz(i,!1),Uz=i=>Gz(i,!0);function Tz(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,A=0,t=0,n;if(e){for(let o of i.state.facet(ui.scrollMargins)){let a=o(i);a?.top&&(A=Math.max(a?.top,A)),a?.bottom&&(t=Math.max(a?.bottom,t))}n=i.scrollDOM.clientHeight-A-t}else n=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:A,marginBottom:t,selfScroll:e,height:Math.max(i.defaultLineHeight,n-5)}}function Oz(i,e){let A=Tz(i),{state:t}=i,n=Qh(t.selection,a=>a.empty?i.moveVertically(a,e,A.height):N8(a,e));if(n.eq(t.selection))return!1;let o;if(A.selfScroll){let a=i.coordsAtPos(t.selection.main.head),r=i.scrollDOM.getBoundingClientRect(),s=r.top+A.marginTop,l=r.bottom-A.marginBottom;a&&a.top>s&&a.bottom<l&&(o=ui.scrollIntoView(n.main.head,{y:"start",yMargin:a.top-s}))}return i.dispatch(dc(t,n),{effects:o}),!0}var yz=i=>Oz(i,!1),ek=i=>Oz(i,!0);function N2(i,e,A){let t=i.lineBlockAt(e.head),n=i.moveToLineBoundary(e,A);if(n.head==e.head&&n.head!=(A?t.to:t.from)&&(n=i.moveToLineBoundary(e,A,!1)),!A&&n.head==t.from&&t.length){let o=/^\s*/.exec(i.state.sliceDoc(t.from,Math.min(t.from+100,t.to)))[0].length;o&&e.head!=t.from+o&&(n=Be.cursor(t.from+o))}return n}var VCA=i=>Ic(i,e=>N2(i,e,!0)),qCA=i=>Ic(i,e=>N2(i,e,!1)),WCA=i=>Ic(i,e=>N2(i,e,!Ds(i))),ZCA=i=>Ic(i,e=>N2(i,e,Ds(i))),XCA=i=>Ic(i,e=>Be.cursor(i.lineBlockAt(e.head).from,1)),$CA=i=>Ic(i,e=>Be.cursor(i.lineBlockAt(e.head).to,-1));function A2A(i,e,A){let t=!1,n=Qh(i.selection,o=>{let a=cc(i,o.head,-1)||cc(i,o.head,1)||o.head>0&&cc(i,o.head-1,1)||o.head<i.doc.length&&cc(i,o.head+1,-1);if(!a||!a.end)return o;t=!0;let r=a.start.from==o.head?a.end.to:a.end.from;return A?Be.range(o.anchor,r):Be.cursor(r)});return t?(e(dc(i,n)),!0):!1}var e2A=({state:i,dispatch:e})=>A2A(i,e,!1);function hg(i,e){let A=Qh(i.state.selection,t=>{let n=e(t);return Be.range(t.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return A.eq(i.state.selection)?!1:(i.dispatch(dc(i.state,A)),!0)}function Jz(i,e){return hg(i,A=>i.moveByChar(A,e))}var Yz=i=>Jz(i,!Ds(i)),Hz=i=>Jz(i,Ds(i));function zz(i,e){return hg(i,A=>i.moveByGroup(A,e))}var t2A=i=>zz(i,!Ds(i)),i2A=i=>zz(i,Ds(i));var n2A=i=>hg(i,e=>F8(i.state,e,!Ds(i))),o2A=i=>hg(i,e=>F8(i.state,e,Ds(i)));function Pz(i,e){return hg(i,A=>i.moveVertically(A,e))}var jz=i=>Pz(i,!1),Vz=i=>Pz(i,!0);function qz(i,e){return hg(i,A=>i.moveVertically(A,e,Tz(i).height))}var Dz=i=>qz(i,!1),vz=i=>qz(i,!0),a2A=i=>hg(i,e=>N2(i,e,!0)),r2A=i=>hg(i,e=>N2(i,e,!1)),s2A=i=>hg(i,e=>N2(i,e,!Ds(i))),l2A=i=>hg(i,e=>N2(i,e,Ds(i))),g2A=i=>hg(i,e=>Be.cursor(i.lineBlockAt(e.head).from)),c2A=i=>hg(i,e=>Be.cursor(i.lineBlockAt(e.head).to)),bz=({state:i,dispatch:e})=>(e(dc(i,{anchor:0})),!0),Mz=({state:i,dispatch:e})=>(e(dc(i,{anchor:i.doc.length})),!0),Sz=({state:i,dispatch:e})=>(e(dc(i,{anchor:i.selection.main.anchor,head:0})),!0),kz=({state:i,dispatch:e})=>(e(dc(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),C2A=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),d2A=({state:i,dispatch:e})=>{let A=L8(i).map(({from:t,to:n})=>Be.range(t,Math.min(n+1,i.doc.length)));return e(i.update({selection:Be.create(A),userEvent:"select"})),!0},I2A=({state:i,dispatch:e})=>{let A=Qh(i.selection,t=>{let n=Kr(i),o=n.resolveStack(t.from,1);if(t.empty){let a=n.resolveStack(t.from,-1);a.node.from>=o.node.from&&a.node.to<=o.node.to&&(o=a)}for(let a=o;a;a=a.next){let{node:r}=a;if((r.from<t.from&&r.to>=t.to||r.to>t.to&&r.from<=t.from)&&a.next)return Be.range(r.to,r.from)}return t});return A.eq(i.selection)?!1:(e(dc(i,A)),!0)};function Wz(i,e){let{state:A}=i,t=A.selection,n=A.selection.ranges.slice();for(let o of A.selection.ranges){let a=A.doc.lineAt(o.head);if(e?a.to<i.state.doc.length:a.from>0)for(let r=o;;){let s=i.moveVertically(r,e);if(s.head<a.from||s.head>a.to){n.some(l=>l.head==s.head)||n.push(s);break}else{if(s.head==r.head)break;r=s}}}return n.length==t.ranges.length?!1:(i.dispatch(dc(A,Be.create(n,n.length-1))),!0)}var B2A=i=>Wz(i,!1),h2A=i=>Wz(i,!0),E2A=({state:i,dispatch:e})=>{let A=i.selection,t=null;return A.ranges.length>1?t=Be.create([A.main]):A.main.empty||(t=Be.create([Be.cursor(A.main.head)])),t?(e(dc(i,t)),!0):!1};function v4(i,e){if(i.state.readOnly)return!1;let A="delete.selection",{state:t}=i,n=t.changeByRange(o=>{let{from:a,to:r}=o;if(a==r){let s=e(o);s<a?(A="delete.backward",s=R8(i,s,!1)):s>a&&(A="delete.forward",s=R8(i,s,!0)),a=Math.min(a,s),r=Math.max(r,s)}else a=R8(i,a,!1),r=R8(i,r,!0);return a==r?{range:o}:{changes:{from:a,to:r},range:Be.cursor(a,a<o.head?-1:1)}});return n.changes.empty?!1:(i.dispatch(t.update(n,{scrollIntoView:!0,userEvent:A,effects:A=="delete.selection"?ui.announce.of(t.phrase("Selection deleted")):void 0})),!0)}function R8(i,e,A){if(i instanceof ui)for(let t of i.state.facet(ui.atomicRanges).map(n=>n(i)))t.between(e,e,(n,o)=>{n<e&&o>e&&(e=A?o:n)});return e}var Zz=(i,e,A)=>v4(i,t=>{let n=t.from,{state:o}=i,a=o.doc.lineAt(n),r,s;if(A&&!e&&n>a.from&&n<a.from+200&&!/[^ \t]/.test(r=a.text.slice(0,n-a.from))){if(r[r.length-1]==" ")return n-1;let l=rC(r,o.tabSize),g=l%Cc(o)||Cc(o);for(let C=0;C<g&&r[r.length-1-C]==" ";C++)n--;s=n}else s=tr(a.text,n-a.from,e,e)+a.from,s==n&&a.number!=(e?o.doc.lines:1)?s+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(s-a.from,n-a.from))&&(s=tr(a.text,s-a.from,!1,!1)+a.from);return s}),tk=i=>Zz(i,!1,!0);var Xz=i=>Zz(i,!0,!1),$z=(i,e)=>v4(i,A=>{let t=A.head,{state:n}=i,o=n.doc.lineAt(t),a=n.charCategorizer(t);for(let r=null;;){if(t==(e?o.to:o.from)){t==A.head&&o.number!=(e?n.doc.lines:1)&&(t+=e?1:-1);break}let s=tr(o.text,t-o.from,e)+o.from,l=o.text.slice(Math.min(t,s)-o.from,Math.max(t,s)-o.from),g=a(l);if(r!=null&&g!=r)break;(l!=" "||t!=A.head)&&(r=g),t=s}return t}),AP=i=>$z(i,!1),Q2A=i=>$z(i,!0);var u2A=i=>v4(i,e=>{let A=i.lineBlockAt(e.head).to;return e.head<A?A:Math.min(i.state.doc.length,e.head+1)});var p2A=i=>v4(i,e=>{let A=i.moveToLineBoundary(e,!1).head;return e.head>A?A:Math.max(0,e.head-1)}),f2A=i=>v4(i,e=>{let A=i.moveToLineBoundary(e,!0).head;return e.head<A?A:Math.min(i.state.doc.length,e.head+1)});var m2A=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let A=i.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:On.of(["",""])},range:Be.cursor(t.from)}));return e(i.update(A,{scrollIntoView:!0,userEvent:"input"})),!0},w2A=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let A=i.changeByRange(t=>{if(!t.empty||t.from==0||t.from==i.doc.length)return{range:t};let n=t.from,o=i.doc.lineAt(n),a=n==o.from?n-1:tr(o.text,n-o.from,!1)+o.from,r=n==o.to?n+1:tr(o.text,n-o.from,!0)+o.from;return{changes:{from:a,to:r,insert:i.doc.slice(n,r).append(i.doc.slice(a,n))},range:Be.cursor(r)}});return A.changes.empty?!1:(e(i.update(A,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function L8(i){let e=[],A=-1;for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),o=i.doc.lineAt(t.to);if(!t.empty&&t.to==o.from&&(o=i.doc.lineAt(t.to-1)),A>=n.number){let a=e[e.length-1];a.to=o.to,a.ranges.push(t)}else e.push({from:n.from,to:o.to,ranges:[t]});A=o.number+1}return e}function eP(i,e,A){if(i.readOnly)return!1;let t=[],n=[];for(let o of L8(i)){if(A?o.to==i.doc.length:o.from==0)continue;let a=i.doc.lineAt(A?o.to+1:o.from-1),r=a.length+1;if(A){t.push({from:o.to,to:a.to},{from:o.from,insert:a.text+i.lineBreak});for(let s of o.ranges)n.push(Be.range(Math.min(i.doc.length,s.anchor+r),Math.min(i.doc.length,s.head+r)))}else{t.push({from:a.from,to:o.from},{from:o.to,insert:i.lineBreak+a.text});for(let s of o.ranges)n.push(Be.range(s.anchor-r,s.head-r))}}return t.length?(e(i.update({changes:t,scrollIntoView:!0,selection:Be.create(n,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}var y2A=({state:i,dispatch:e})=>eP(i,e,!1),D2A=({state:i,dispatch:e})=>eP(i,e,!0);function tP(i,e,A){if(i.readOnly)return!1;let t=[];for(let o of L8(i))A?t.push({from:o.from,insert:i.doc.slice(o.from,o.to)+i.lineBreak}):t.push({from:o.to,insert:i.lineBreak+i.doc.slice(o.from,o.to)});let n=i.changes(t);return e(i.update({changes:n,selection:i.selection.map(n,A?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var v2A=({state:i,dispatch:e})=>tP(i,e,!1),b2A=({state:i,dispatch:e})=>tP(i,e,!0),M2A=i=>{if(i.state.readOnly)return!1;let{state:e}=i,A=e.changes(L8(e).map(({from:n,to:o})=>(n>0?n--:o<e.doc.length&&o++,{from:n,to:o}))),t=Qh(e.selection,n=>{let o;if(i.lineWrapping){let a=i.lineBlockAt(n.head),r=i.coordsAtPos(n.head,n.assoc||1);r&&(o=a.bottom+i.documentTop-r.bottom+i.defaultLineHeight/2)}return i.moveVertically(n,!0,o)}).map(A);return i.dispatch({changes:A,selection:t,scrollIntoView:!0,userEvent:"delete.line"}),!0};function S2A(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let A=Kr(i).resolveInner(e),t=A.childBefore(e),n=A.childAfter(e),o;return t&&n&&t.to<=e&&n.from>=e&&(o=t.type.prop(Hi.closedBy))&&o.indexOf(n.name)>-1&&i.doc.lineAt(t.to).from==i.doc.lineAt(n.from).from&&!/\S/.test(i.sliceDoc(t.to,n.from))?{from:t.to,to:n.from}:null}var _z=iP(!1),k2A=iP(!0);function iP(i){return({state:e,dispatch:A})=>{if(e.readOnly)return!1;let t=e.changeByRange(n=>{let{from:o,to:a}=n,r=e.doc.lineAt(o),s=!i&&o==a&&S2A(e,o);i&&(o=a=(a<=r.to?r:e.doc.lineAt(a)).to);let l=new _d(e,{simulateBreak:o,simulateDoubleBreak:!!s}),g=x8(l,o);for(g==null&&(g=rC(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));a<r.to&&/\s/.test(r.text[a-r.from]);)a++;s?{from:o,to:a}=s:o>r.from&&o<r.from+100&&!/\S/.test(r.text.slice(0,o))&&(o=r.from);let C=["",hh(e,g)];return s&&C.push(hh(e,l.lineIndent(r.from,-1))),{changes:{from:o,to:a,insert:On.of(C)},range:Be.cursor(o+1+C[1].length)}});return A(e.update(t,{scrollIntoView:!0,userEvent:"input"})),!0}}function ok(i,e){let A=-1;return i.changeByRange(t=>{let n=[];for(let a=t.from;a<=t.to;){let r=i.doc.lineAt(a);r.number>A&&(t.empty||t.to>r.from)&&(e(r,n,t),A=r.number),a=r.to+1}let o=i.changes(n);return{changes:n,range:Be.range(o.mapPos(t.anchor,1),o.mapPos(t.head,1))}})}var _2A=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let A=Object.create(null),t=new _d(i,{overrideIndentation:o=>{let a=A[o];return a??-1}}),n=ok(i,(o,a,r)=>{let s=x8(t,o.from);if(s==null)return;/\S/.test(o.text)||(s=0);let l=/^\s*/.exec(o.text)[0],g=hh(i,s);(l!=g||r.from<o.from+l.length)&&(A[o.from]=s,a.push({from:o.from,to:o.from+l.length,insert:g}))});return n.changes.empty||e(i.update(n,{userEvent:"indent"})),!0},nP=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ok(i,(A,t)=>{t.push({from:A.from,insert:i.facet(Rd)})}),{userEvent:"input.indent"})),!0),oP=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ok(i,(A,t)=>{let n=/^\s*/.exec(A.text)[0];if(!n)return;let o=rC(n,i.tabSize),a=0,r=hh(i,Math.max(0,o-Cc(i)));for(;a<n.length&&a<r.length&&n.charCodeAt(a)==r.charCodeAt(a);)a++;t.push({from:A.from+a,to:A.from+n.length,insert:r.slice(a)})}),{userEvent:"delete.dedent"})),!0),x2A=i=>(i.setTabFocusMode(),!0);var R2A=[{key:"Ctrl-b",run:Nz,shift:Yz,preventDefault:!0},{key:"Ctrl-f",run:Fz,shift:Hz},{key:"Ctrl-p",run:Kz,shift:jz},{key:"Ctrl-n",run:Uz,shift:Vz},{key:"Ctrl-a",run:XCA,shift:g2A},{key:"Ctrl-e",run:$CA,shift:c2A},{key:"Ctrl-d",run:Xz},{key:"Ctrl-h",run:tk},{key:"Ctrl-k",run:u2A},{key:"Ctrl-Alt-h",run:AP},{key:"Ctrl-o",run:m2A},{key:"Ctrl-t",run:w2A},{key:"Ctrl-v",run:ek}],N2A=[{key:"ArrowLeft",run:Nz,shift:Yz,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:YCA,shift:t2A,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:WCA,shift:s2A,preventDefault:!0},{key:"ArrowRight",run:Fz,shift:Hz,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:HCA,shift:i2A,preventDefault:!0},{mac:"Cmd-ArrowRight",run:ZCA,shift:l2A,preventDefault:!0},{key:"ArrowUp",run:Kz,shift:jz,preventDefault:!0},{mac:"Cmd-ArrowUp",run:bz,shift:Sz},{mac:"Ctrl-ArrowUp",run:yz,shift:Dz},{key:"ArrowDown",run:Uz,shift:Vz,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Mz,shift:kz},{mac:"Ctrl-ArrowDown",run:ek,shift:vz},{key:"PageUp",run:yz,shift:Dz},{key:"PageDown",run:ek,shift:vz},{key:"Home",run:qCA,shift:r2A,preventDefault:!0},{key:"Mod-Home",run:bz,shift:Sz},{key:"End",run:VCA,shift:a2A,preventDefault:!0},{key:"Mod-End",run:Mz,shift:kz},{key:"Enter",run:_z,shift:_z},{key:"Mod-a",run:C2A},{key:"Backspace",run:tk,shift:tk,preventDefault:!0},{key:"Delete",run:Xz,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:AP,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Q2A,preventDefault:!0},{mac:"Mod-Backspace",run:p2A,preventDefault:!0},{mac:"Mod-Delete",run:f2A,preventDefault:!0}].concat(R2A.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),aP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:PCA,shift:n2A},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:jCA,shift:o2A},{key:"Alt-ArrowUp",run:y2A},{key:"Shift-Alt-ArrowUp",run:v2A},{key:"Alt-ArrowDown",run:D2A},{key:"Shift-Alt-ArrowDown",run:b2A},{key:"Mod-Alt-ArrowUp",run:B2A},{key:"Mod-Alt-ArrowDown",run:h2A},{key:"Escape",run:E2A},{key:"Mod-Enter",run:k2A},{key:"Alt-l",mac:"Ctrl-l",run:d2A},{key:"Mod-i",run:I2A,preventDefault:!0},{key:"Mod-[",run:oP},{key:"Mod-]",run:nP},{key:"Mod-Alt-\\",run:_2A},{key:"Shift-Mod-k",run:M2A},{key:"Shift-Mod-\\",run:e2A},{key:"Mod-/",run:LCA},{key:"Alt-A",run:KCA},{key:"Ctrl-m",mac:"Shift-Alt-m",run:x2A}].concat(N2A),rP={key:"Tab",run:nP,shift:oP};var U8=class{constructor(e,A,t){this.from=e,this.to=A,this.diagnostic=t}},Nd=class i{constructor(e,A,t){this.diagnostics=e,this.panel=A,this.selected=t}static init(e,A,t){let n=t.facet(E0).markerFilter;n&&(e=n(e,t));let o=e.slice().sort((B,u)=>B.from-u.from||B.to-u.to),a=new Xr,r=[],s=0,l=t.doc.iter(),g=0,C=t.doc.length;for(let B=0;;){let u=B==o.length?null:o[B];if(!u&&!r.length)break;let E,f;if(r.length)E=s,f=r.reduce((S,k)=>Math.min(S,k.to),u&&u.from>E?u.from:1e8);else{if(E=u.from,E>C)break;f=u.to,r.push(u),B++}for(;B<o.length;){let S=o[B];if(S.from==E&&(S.to>S.from||S.to==E))r.push(S),B++,f=Math.min(S.to,f);else{f=Math.min(S.from,f);break}}f=Math.min(f,C);let m=!1;if(r.some(S=>S.from==E&&(S.to==f||f==C))&&(m=E==f,!m&&f-E<10)){let S=E-(g+l.value.length);S>0&&(l.next(S),g=E);for(let k=E;;){if(k>=f){m=!0;break}if(!l.lineBreak&&g+l.value.length>k)break;k=g+l.value.length,g+=l.value.length,l.next()}}let v=QP(r);if(m)a.add(E,E,Lt.widget({widget:new ak(v),diagnostics:r.slice()}));else{let S=r.reduce((k,M)=>M.markClass?k+" "+M.markClass:k,"");a.add(E,f,Lt.mark({class:"cm-lintRange cm-lintRange-"+v+S,diagnostics:r.slice(),inclusiveEnd:r.some(k=>k.to>f)}))}if(s=f,s==C)break;for(let S=0;S<r.length;S++)r[S].to<=s&&r.splice(S--,1)}let d=a.finish();return new i(d,A,F2(d))}};function F2(i,e=null,A=0){let t=null;return i.between(A,1e9,(n,o,{spec:a})=>{if(!(e&&a.diagnostics.indexOf(e)<0))if(!t)t=new U8(n,o,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(t.diagnostic)<0)return!1;t=new U8(t.from,o,t.diagnostic)}}),t}function gP(i,e){let A=e.pos,t=e.end||A,n=i.state.facet(E0).hideOn(i,A,t);if(n!=null)return n;let o=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(a=>a.is(J8))||i.changes.touchesRange(o.from,Math.max(o.to,t)))}function cP(i,e){return i.field(Fl,!1)?e:e.concat(ln.appendConfig.of(pP))}function F2A(i,e){return{effects:cP(i,[J8.of(e)])}}var J8=ln.define(),sk=ln.define(),CP=ln.define(),Fl=La.define({create(){return new Nd(Lt.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let A=i.diagnostics.map(e.changes),t=null,n=i.panel;if(i.selected){let o=e.changes.mapPos(i.selected.from,1);t=F2(A,i.selected.diagnostic,o)||F2(A,null,o)}!A.size&&n&&e.state.facet(E0).autoPanel&&(n=null),i=new Nd(A,n,t)}for(let A of e.effects)if(A.is(J8)){let t=e.state.facet(E0).autoPanel?A.value.length?b4.open:null:i.panel;i=Nd.init(A.value,t,e.state)}else A.is(sk)?i=new Nd(i.diagnostics,A.value?b4.open:null,i.selected):A.is(CP)&&(i=new Nd(i.diagnostics,i.panel,A.value));return i},provide:i=>[vd.from(i,e=>e.panel),ui.decorations.from(i,e=>e.diagnostics)]});var L2A=Lt.mark({class:"cm-lintRange cm-lintRange-active"});function G2A(i,e,A){let{diagnostics:t}=i.state.field(Fl),n,o=-1,a=-1;t.between(e-(A<0?1:0),e+(A>0?1:0),(s,l,{spec:g})=>{if(e>=s&&e<=l&&(s==l||(e>s||A>0)&&(e<l||A<0)))return n=g.diagnostics,o=s,a=l,!1});let r=i.state.facet(E0).tooltipFilter;return n&&r&&(n=r(n,i.state)),n?{pos:o,end:a,above:i.state.doc.lineAt(o).to<a,create(){return{dom:dP(i,n)}}}:null}function dP(i,e){return po("ul",{class:"cm-tooltip-lint"},e.map(A=>EP(i,A,!1)))}var K2A=i=>{let e=i.state.field(Fl,!1);(!e||!e.panel)&&i.dispatch({effects:cP(i.state,[sk.of(!0)])});let A=d4(i,b4.open);return A&&A.dom.querySelector(".cm-panel-lint ul").focus(),!0},sP=i=>{let e=i.state.field(Fl,!1);return!e||!e.panel?!1:(i.dispatch({effects:sk.of(!1)}),!0)},U2A=i=>{let e=i.state.field(Fl,!1);if(!e)return!1;let A=i.state.selection.main,t=F2(e.diagnostics,null,A.to+1);return!t&&(t=F2(e.diagnostics,null,0),!t||t.from==A.from&&t.to==A.to)?!1:(i.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),!0)};var IP=[{key:"Mod-Shift-m",run:K2A,preventDefault:!0},{key:"F8",run:U2A}],T2A=Po.fromClass(class{constructor(i){this.view=i,this.timeout=-1,this.set=!0;let{delay:e}=i.state.facet(E0);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let i=Date.now();if(i<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-i);else{this.set=!1;let{state:e}=this.view,{sources:A}=e.facet(E0);A.length&&O2A(A.map(t=>Promise.resolve(t(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(F2A(this.view.state,t.reduce((n,o)=>n.concat(o))))},t=>{Gr(this.view.state,t)})}}update(i){let e=i.state.facet(E0);(i.docChanged||e!=i.startState.facet(E0)||e.needsRefresh&&e.needsRefresh(i))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function O2A(i,e,A){let t=[],n=-1;for(let o of i)o.then(a=>{t.push(a),clearTimeout(n),t.length==i.length?e(t):n=setTimeout(()=>e(t),200)},A)}var E0=nt.define({combine(i){return P({sources:i.map(e=>e.source).filter(e=>e!=null)},Lr(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lP,tooltipFilter:lP,needsRefresh:(e,A)=>e?A?t=>e(t)||A(t):e:A,hideOn:(e,A)=>e?A?(t,n,o)=>e(t,n,o)||A(t,n,o):e:A,autoPanel:(e,A)=>e||A}))}});function lP(i,e){return i?e?(A,t)=>e(i(A,t),t):i:e}function BP(i,e={}){return[E0.of({source:i,config:e}),T2A,pP]}function hP(i){let e=[];if(i)A:for(let{name:A}of i){for(let t=0;t<A.length;t++){let n=A[t];if(/[a-zA-Z]/.test(n)&&!e.some(o=>o.toLowerCase()==n.toLowerCase())){e.push(n);continue A}}e.push("")}return e}function EP(i,e,A){var t;let n=A?hP(e.actions):[];return po("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},po("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(t=e.actions)===null||t===void 0?void 0:t.map((o,a)=>{let r=!1,s=B=>{if(B.preventDefault(),r)return;r=!0;let u=F2(i.state.field(Fl).diagnostics,e);u&&o.apply(i,u.from,u.to)},{name:l}=o,g=n[a]?l.indexOf(n[a]):-1,C=g<0?l:[l.slice(0,g),po("u",l.slice(g,g+1)),l.slice(g+1)],d=o.markClass?" "+o.markClass:"";return po("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:s,onmousedown:s,"aria-label":` Action: ${l}${g<0?"":` (access key "${n[a]})"`}.`},C)}),e.source&&po("div",{class:"cm-diagnosticSource"},e.source))}var ak=class extends gl{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return po("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},T8=class{constructor(e,A){this.diagnostic=A,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=EP(e,A,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},b4=class i{constructor(e){this.view=e,this.items=[];let A=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)sP(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],a=hP(o.actions);for(let r=0;r<a.length;r++)if(a[r].toUpperCase().charCodeAt(0)==n.keyCode){let s=F2(this.view.state.field(Fl).diagnostics,o);s&&o.actions[r].apply(e,s.from,s.to)}}else return;n.preventDefault()}},t=n=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(n.target)&&this.moveSelection(o)};this.list=po("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:A,onclick:t}),this.dom=po("div",{class:"cm-panel-lint"},this.list,po("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Fl).selected;if(!e)return-1;for(let A=0;A<this.items.length;A++)if(this.items[A].diagnostic==e.diagnostic)return A;return-1}update(){let{diagnostics:e,selected:A}=this.view.state.field(Fl),t=0,n=!1,o=null,a=new Set;for(e.between(0,this.view.state.doc.length,(r,s,{spec:l})=>{for(let g of l.diagnostics){if(a.has(g))continue;a.add(g);let C=-1,d;for(let B=t;B<this.items.length;B++)if(this.items[B].diagnostic==g){C=B;break}C<0?(d=new T8(this.view,g),this.items.splice(t,0,d),n=!0):(d=this.items[C],C>t&&(this.items.splice(t,C-t),n=!0)),A&&d.diagnostic==A.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),o=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),t++}});t<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new T8(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:r,panel:s})=>{let l=s.height/this.list.offsetHeight;r.top<s.top?this.list.scrollTop-=(s.top-r.top)/l:r.bottom>s.bottom&&(this.list.scrollTop+=(r.bottom-s.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function A(){let t=e;e=t.nextSibling,t.remove()}for(let t of this.items)if(t.dom.parentNode==this.list){for(;e!=t.dom;)A();e=t.dom.nextSibling}else this.list.insertBefore(t.dom,e);for(;e;)A()}moveSelection(e){if(this.selectedIndex<0)return;let A=this.view.state.field(Fl),t=F2(A.diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:CP.of(t)})}static open(e){return new i(e)}};function K8(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function G8(i){return K8(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var J2A=ui.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:G8("#d11")},".cm-lintRange-warning":{backgroundImage:G8("orange")},".cm-lintRange-info":{backgroundImage:G8("#999")},".cm-lintRange-hint":{backgroundImage:G8("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Y2A(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function QP(i){let e="hint",A=1;for(let t of i){let n=Y2A(t.severity);n>A&&(A=n,e=t.severity)}return e}var O8=class extends Cl{constructor(e){super(),this.diagnostics=e,this.severity=QP(e)}toDOM(e){let A=document.createElement("div");A.className="cm-lint-marker cm-lint-marker-"+this.severity;let t=this.diagnostics,n=e.state.facet(Y8).tooltipFilter;return n&&(t=n(t,e.state)),t.length&&(A.onmouseover=()=>z2A(e,A,t)),A}};function H2A(i,e){let A=t=>{let n=e.getBoundingClientRect();if(!(t.clientX>n.left-10&&t.clientX<n.right+10&&t.clientY>n.top-10&&t.clientY<n.bottom+10)){for(let o=t.target;o;o=o.parentNode)if(o.nodeType==1&&o.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",A),i.state.field(uP)&&i.dispatch({effects:lk.of(null)})}};window.addEventListener("mousemove",A)}function z2A(i,e,A){function t(){let a=i.elementAtHeight(e.getBoundingClientRect().top+5-i.documentTop);i.coordsAtPos(a.from)&&i.dispatch({effects:lk.of({pos:a.from,above:!1,clip:!1,create(){return{dom:dP(i,A),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,H2A(i,e)}let{hoverTime:n}=i.state.facet(Y8),o=setTimeout(t,n);e.onmouseout=()=>{clearTimeout(o),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(o),o=setTimeout(t,n)}}function P2A(i,e){let A=Object.create(null);for(let n of e){let o=i.lineAt(n.from);(A[o.from]||(A[o.from]=[])).push(n)}let t=[];for(let n in A)t.push(new O8(A[n]).range(+n));return uo.of(t,!0)}var j2A=p8({class:"cm-gutter-lint",markers:i=>i.state.field(rk),widgetMarker:(i,e,A)=>{let t=[];return i.state.field(rk).between(A.from,A.to,(n,o,a)=>{n>A.from&&n<A.to&&t.push(...a.diagnostics)}),t.length?new O8(t):null}}),rk=La.define({create(){return uo.empty},update(i,e){i=i.map(e.changes);let A=e.state.facet(Y8).markerFilter;for(let t of e.effects)if(t.is(J8)){let n=t.value;A&&(n=A(n||[],e.state)),i=P2A(e.state.doc,n.slice(0))}return i}}),lk=ln.define(),uP=La.define({create(){return null},update(i,e){return i&&e.docChanged&&(i=gP(e,i)?null:$A(P({},i),{pos:e.changes.mapPos(i.pos)})),e.effects.reduce((A,t)=>t.is(lk)?t.value:A,i)},provide:i=>ch.from(i)}),V2A=ui.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:K8('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:K8('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:K8('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),pP=[Fl,ui.decorations.compute([Fl],i=>{let{selected:e,panel:A}=i.field(Fl);return!e||!A||e.from==e.to?Lt.none:Lt.set([L2A.range(e.from,e.to)])}),FH(G2A,{hideOn:gP}),J2A],Y8=nt.define({combine(i){return Lr(i,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fP(i={}){return[Y8.of(i),rk,j2A,V2A,uP]}var ck=class i{constructor(e,A,t,n,o,a,r,s,l,g=0,C){this.p=e,this.stack=A,this.state=t,this.reducePos=n,this.pos=o,this.score=a,this.buffer=r,this.bufferBase=s,this.curContext=l,this.lookAhead=g,this.parent=C}toString(){return`[${this.stack.filter((e,A)=>A%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,A,t=0){let n=e.parser.context;return new i(e,[],A,t,t,0,[],0,n?new H8(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,A){this.stack.push(this.state,A,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var A;let t=e>>19,n=e&65535,{parser:o}=this.p,a=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),r=o.dynamicPrecedence(n);if(r&&(this.score+=r),t==0){this.pushState(o.getGoto(this.state,n,!0),this.reducePos),n<o.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,a?8:4,!0),this.reduceContext(n,this.reducePos);return}let s=this.stack.length-(t-1)*3-(e&262144?6:0),l=s?this.stack[s-2]:this.p.ranges[0].from,g=this.reducePos-l;g>=2e3&&!(!((A=this.p.parser.nodeSet.types[n])===null||A===void 0)&&A.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=g):this.p.lastBigReductionSize<g&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=g));let C=s?this.stack[s-1]:0,d=this.bufferBase+this.buffer.length-C;if(n<o.minRepeatTerm||e&131072){let B=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,l,B,d+4,!0)}if(e&262144)this.state=this.stack[s];else{let B=this.stack[s-3];this.state=o.getGoto(B,n,!0)}for(;this.stack.length>s;)this.stack.pop();this.reduceContext(n,l)}storeNode(e,A,t,n=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let a=this,r=this.buffer.length;if(r==0&&a.parent&&(r=a.bufferBase-a.parent.bufferBase,a=a.parent),r>0&&a.buffer[r-4]==0&&a.buffer[r-1]>-1){if(A==t)return;if(a.buffer[r-2]>=A){a.buffer[r-2]=t;return}}}if(!o||this.pos==t)this.buffer.push(e,A,t,n);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let r=!1;for(let s=a;s>0&&this.buffer[s-2]>t;s-=4)if(this.buffer[s-1]>=0){r=!0;break}if(r)for(;a>0&&this.buffer[a-2]>t;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,n>4&&(n-=4)}this.buffer[a]=e,this.buffer[a+1]=A,this.buffer[a+2]=t,this.buffer[a+3]=n}}shift(e,A,t,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:a}=this.p;this.pos=n;let r=a.stateFlag(o,1);!r&&(n>t||A<=a.maxNode)&&(this.reducePos=n),this.pushState(o,r?t:Math.min(t,this.reducePos)),this.shiftContext(A,t),A<=a.maxNode&&this.buffer.push(A,t,n,4)}else this.pos=n,this.shiftContext(A,t),A<=this.p.parser.maxNode&&this.buffer.push(A,t,n,4)}apply(e,A,t,n){e&65536?this.reduce(e):this.shift(e,A,t,n)}useNode(e,A){let t=this.p.reused.length-1;(t<0||this.p.reused[t]!=e)&&(this.p.reused.push(e),t++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(A,n),this.buffer.push(t,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,A=e.buffer.length;for(;A>0&&e.buffer[A-2]>e.reducePos;)A-=4;let t=e.buffer.slice(A),n=e.bufferBase+A;for(;e&&n==e.bufferBase;)e=e.parent;return new i(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,t,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,A){let t=e<=this.p.parser.maxNode;t&&this.storeNode(e,this.pos,A,4),this.storeNode(0,this.pos,A,t?8:4),this.pos=this.reducePos=A,this.score-=190}canShift(e){for(let A=new Ck(this);;){let t=this.p.parser.stateSlot(A.state,4)||this.p.parser.hasAction(A.state,e);if(t==0)return!1;if((t&65536)==0)return!0;A.reduce(t)}}recoverByInsert(e){if(this.stack.length>=300)return[];let A=this.p.parser.nextStates(this.state);if(A.length>8||this.stack.length>=120){let n=[];for(let o=0,a;o<A.length;o+=2)(a=A[o+1])!=this.state&&this.p.parser.hasAction(a,e)&&n.push(A[o],a);if(this.stack.length<120)for(let o=0;n.length<8&&o<A.length;o+=2){let a=A[o+1];n.some((r,s)=>s&1&&r==a)||n.push(A[o],a)}A=n}let t=[];for(let n=0;n<A.length&&t.length<4;n+=2){let o=A[n+1];if(o==this.state)continue;let a=this.split();a.pushState(o,this.pos),a.storeNode(0,a.pos,a.pos,4,!0),a.shiftContext(A[n],this.pos),a.reducePos=this.pos,a.score-=200,t.push(a)}return t}forceReduce(){let{parser:e}=this.p,A=e.stateSlot(this.state,5);if((A&65536)==0)return!1;if(!e.validAction(this.state,A)){let t=A>>19,n=A&65535,o=this.stack.length-t*3;if(o<0||e.getGoto(this.stack[o],n,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;A=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(A),!0}findForcedReduction(){let{parser:e}=this.p,A=[],t=(n,o)=>{if(!A.includes(n))return A.push(n),e.allActions(n,a=>{if(!(a&393216))if(a&65536){let r=(a>>19)-o;if(r>1){let s=a&65535,l=this.stack.length-r*3;if(l>=0&&e.getGoto(this.stack[l],s,!1)>=0)return r<<19|65536|s}}else{let r=t(a,o+1);if(r!=null)return r}})};return t(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let A=0;A<this.stack.length;A+=3)if(this.stack[A]!=e.stack[A])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,A){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(A)))}reduceContext(e,A){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(A)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let A=new H8(this.curContext.tracker,e);A.hash!=this.curContext.hash&&this.emitContext(),this.curContext=A}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},H8=class{constructor(e,A){this.tracker=e,this.context=A,this.hash=e.strict?e.hash(A):0}},Ck=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let A=e&65535,t=e>>19;t==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],A,!0);this.state=n}},dk=class i{constructor(e,A,t){this.stack=e,this.pos=A,this.index=t,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,A=e.bufferBase+e.buffer.length){return new i(e,A,A-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new i(this.stack,this.pos,this.index)}};function M4(i,e=Uint16Array){if(typeof i!="string")return i;let A=null;for(let t=0,n=0;t<i.length;){let o=0;for(;;){let a=i.charCodeAt(t++),r=!1;if(a==126){o=65535;break}a>=92&&a--,a>=34&&a--;let s=a-32;if(s>=46&&(s-=46,r=!0),o+=s,r)break;o*=46}A?A[n++]=o:A=new e(o)}return A}var uh=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},mP=new uh,Ik=class{constructor(e,A){this.input=e,this.ranges=A,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mP,this.rangeIndex=0,this.pos=this.chunkPos=A[0].from,this.range=A[0],this.end=A[A.length-1].to,this.readNext()}resolveOffset(e,A){let t=this.range,n=this.rangeIndex,o=this.pos+e;for(;o<t.from;){if(!n)return null;let a=this.ranges[--n];o-=t.from-a.to,t=a}for(;A<0?o>t.to:o>=t.to;){if(n==this.ranges.length-1)return null;let a=this.ranges[++n];o+=a.from-t.to,t=a}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let A of this.ranges)if(A.to>e)return Math.max(e,A.from);return this.end}peek(e){let A=this.chunkOff+e,t,n;if(A>=0&&A<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(A);else{let o=this.resolveOffset(e,1);if(o==null)return-1;if(t=o,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let a=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++a];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,A=0){let t=A?this.resolveOffset(A,-1):this.pos;if(t==null||t<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=t}acceptTokenTo(e,A){this.token.value=e,this.token.end=A}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:A}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=A,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),A=this.pos+e.length;this.chunk=A>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,A){if(A?(this.token=A,A.start=e,A.lookAhead=e+1,A.value=A.extended=-1):this.token=mP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,A){if(e>=this.chunkPos&&A<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,A-this.chunkPos);if(e>=this.chunk2Pos&&A<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,A-this.chunk2Pos);if(e>=this.range.from&&A<=this.range.to)return this.input.read(e,A);let t="";for(let n of this.ranges){if(n.from>=A)break;n.to>e&&(t+=this.input.read(Math.max(n.from,e),Math.min(n.to,A)))}return t}},L2=class{constructor(e,A){this.data=e,this.id=A}token(e,A){let{parser:t}=A.p;bP(this.data,e,A,this.id,t.data,t.tokenPrecTable)}};L2.prototype.contextual=L2.prototype.fallback=L2.prototype.extend=!1;var Bk=class{constructor(e,A,t){this.precTable=A,this.elseToken=t,this.data=typeof e=="string"?M4(e):e}token(e,A){let t=e.pos,n=0;for(;;){let o=e.next<0,a=e.resolveOffset(1,1);if(bP(this.data,e,A,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(o||n++,a==null)break;e.reset(a,e.token)}n&&(e.reset(t,e.token),e.acceptToken(this.elseToken,n))}};Bk.prototype.contextual=L2.prototype.fallback=L2.prototype.extend=!1;function bP(i,e,A,t,n,o){let a=0,r=1<<t,{dialect:s}=A.p.parser;A:for(;(r&i[a])!=0;){let l=i[a+1];for(let B=a+3;B<l;B+=2)if((i[B+1]&r)>0){let u=i[B];if(s.allows(u)&&(e.token.value==-1||e.token.value==u||W2A(u,e.token.value,n,o))){e.acceptToken(u);break}}let g=e.next,C=0,d=i[a+2];if(e.next<0&&d>C&&i[l+d*3-3]==65535){a=i[l+d*3-1];continue A}for(;C<d;){let B=C+d>>1,u=l+B+(B<<1),E=i[u],f=i[u+1]||65536;if(g<E)d=B;else if(g>=f)C=B+1;else{a=i[u+2],e.advance();continue A}}break}}function wP(i,e,A){for(let t=e,n;(n=i[t])!=65535;t++)if(n==A)return t-e;return-1}function W2A(i,e,A,t){let n=wP(A,t,e);return n<0||wP(A,t,i)<n}var Ll=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),gk=null;function yP(i,e,A){let t=i.cursor(Ga.IncludeAnonymous);for(t.moveTo(e);;)if(!(A<0?t.childBefore(e):t.childAfter(e)))for(;;){if((A<0?t.to<e:t.from>e)&&!t.type.isError)return A<0?Math.max(0,Math.min(t.to-1,e-25)):Math.min(i.length,Math.max(t.from+1,e+25));if(A<0?t.prevSibling():t.nextSibling())break;if(!t.parent())return A<0?0:i.length}}var hk=class{constructor(e,A){this.fragments=e,this.nodeSet=A,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?yP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?yP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let A=this.trees.length-1;if(A<0)return this.nextFragment(),null;let t=this.trees[A],n=this.index[A];if(n==t.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=t.children[n],a=this.start[A]+t.positions[n];if(a>e)return this.nextStart=a,null;if(o instanceof Pa){if(a==e){if(a<this.safeFrom)return null;let r=a+o.length;if(r<=this.safeTo){let s=o.prop(Hi.lookAhead);if(!s||r+s<this.fragment.to)return o}}this.index[A]++,a+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(a),this.index.push(0))}else this.index[A]++,this.nextStart=a+o.length}}},Ek=class{constructor(e,A){this.stream=A,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(t=>new uh)}getActions(e){let A=0,t=null,{parser:n}=e.p,{tokenizers:o}=n,a=n.stateSlot(e.state,3),r=e.curContext?e.curContext.hash:0,s=0;for(let l=0;l<o.length;l++){if((1<<l&a)==0)continue;let g=o[l],C=this.tokens[l];if(!(t&&!g.fallback)&&((g.contextual||C.start!=e.pos||C.mask!=a||C.context!=r)&&(this.updateCachedToken(C,g,e),C.mask=a,C.context=r),C.lookAhead>C.end+25&&(s=Math.max(C.lookAhead,s)),C.value!=0)){let d=A;if(C.extended>-1&&(A=this.addActions(e,C.extended,C.end,A)),A=this.addActions(e,C.value,C.end,A),!g.extend&&(t=C,A>d))break}}for(;this.actions.length>A;)this.actions.pop();return s&&e.setLookAhead(s),!t&&e.pos==this.stream.end&&(t=new uh,t.value=e.p.parser.eofTerm,t.start=t.end=e.pos,A=this.addActions(e,t.value,t.end,A)),this.mainToken=t,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let A=new uh,{pos:t,p:n}=e;return A.start=t,A.end=Math.min(t+1,n.stream.end),A.value=t==n.stream.end?n.parser.eofTerm:0,A}updateCachedToken(e,A,t){let n=this.stream.clipPos(t.pos);if(A.token(this.stream.reset(n,e),t),e.value>-1){let{parser:o}=t.p;for(let a=0;a<o.specialized.length;a++)if(o.specialized[a]==e.value){let r=o.specializers[a](this.stream.read(e.start,e.end),t);if(r>=0&&t.p.parser.dialect.allows(r>>1)){(r&1)==0?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,A,t,n){for(let o=0;o<n;o+=3)if(this.actions[o]==e)return n;return this.actions[n++]=e,this.actions[n++]=A,this.actions[n++]=t,n}addActions(e,A,t,n){let{state:o}=e,{parser:a}=e.p,{data:r}=a;for(let s=0;s<2;s++)for(let l=a.stateSlot(o,s?2:1);;l+=3){if(r[l]==65535)if(r[l+1]==1)l=CC(r,l+2);else{n==0&&r[l+1]==2&&(n=this.putAction(CC(r,l+2),A,t,n));break}r[l]==A&&(n=this.putAction(CC(r,l+1),A,t,n))}return n}},Qk=class{constructor(e,A,t,n){this.parser=e,this.input=A,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Ik(A,n),this.tokens=new Ek(e,this.stream),this.topTerm=e.top[1];let{from:o}=n[0];this.stacks=[ck.start(this,e.top[0],o)],this.fragments=t.length&&this.stream.end-o>e.bufferLength*4?new hk(t,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,A=this.minStackPos,t=this.stacks=[],n,o;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let r=e[a];for(;;){if(this.tokens.mainToken=null,r.pos>A)t.push(r);else{if(this.advanceStack(r,t,e))continue;{n||(n=[],o=[]),n.push(r);let s=this.tokens.getMainToken(r);o.push(s.value,s.end)}}break}}if(!t.length){let a=n&&Z2A(n);if(a)return Ll&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Ll&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+A);this.recovering||(this.recovering=5)}if(this.recovering&&n){let a=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,o,t);if(a)return Ll&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(t.length>a)for(t.sort((r,s)=>s.score-r.score);t.length>a;)t.pop();t.some(r=>r.reducePos>A)&&this.recovering--}else if(t.length>1){A:for(let a=0;a<t.length-1;a++){let r=t[a];for(let s=a+1;s<t.length;s++){let l=t[s];if(r.sameState(l)||r.buffer.length>500&&l.buffer.length>500)if((r.score-l.score||r.buffer.length-l.buffer.length)>0)t.splice(s--,1);else{t.splice(a--,1);continue A}}}t.length>12&&(t.sort((a,r)=>r.score-a.score),t.splice(12,t.length-12))}this.minStackPos=t[0].pos;for(let a=1;a<t.length;a++)t[a].pos<this.minStackPos&&(this.minStackPos=t[a].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,A,t){let n=e.pos,{parser:o}=this,a=Ll?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let l=e.curContext&&e.curContext.tracker.strict,g=l?e.curContext.hash:0;for(let C=this.fragments.nodeAt(n);C;){let d=this.parser.nodeSet.types[C.type.id]==C.type?o.getGoto(e.state,C.type.id):-1;if(d>-1&&C.length&&(!l||(C.prop(Hi.contextHash)||0)==g))return e.useNode(C,d),Ll&&console.log(a+this.stackID(e)+` (via reuse of ${o.getName(C.type.id)})`),!0;if(!(C instanceof Pa)||C.children.length==0||C.positions[0]>0)break;let B=C.children[0];if(B instanceof Pa&&C.positions[0]==0)C=B;else break}}let r=o.stateSlot(e.state,4);if(r>0)return e.reduce(r),Ll&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(r&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let l=0;l<s.length;){let g=s[l++],C=s[l++],d=s[l++],B=l==s.length||!t,u=B?e:e.split(),E=this.tokens.mainToken;if(u.apply(g,C,E?E.start:u.pos,d),Ll&&console.log(a+this.stackID(u)+` (via ${(g&65536)==0?"shift":`reduce of ${o.getName(g&65535)}`} for ${o.getName(C)} @ ${n}${u==e?"":", split"})`),B)return!0;u.pos>n?A.push(u):t.push(u)}return!1}advanceFully(e,A){let t=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>t)return DP(e,A),!0}}runRecovery(e,A,t){let n=null,o=!1;for(let a=0;a<e.length;a++){let r=e[a],s=A[a<<1],l=A[(a<<1)+1],g=Ll?this.stackID(r)+" -> ":"";if(r.deadEnd&&(o||(o=!0,r.restart(),Ll&&console.log(g+this.stackID(r)+" (restarted)"),this.advanceFully(r,t))))continue;let C=r.split(),d=g;for(let B=0;B<10&&C.forceReduce()&&(Ll&&console.log(d+this.stackID(C)+" (via force-reduce)"),!this.advanceFully(C,t));B++)Ll&&(d=this.stackID(C)+" -> ");for(let B of r.recoverByInsert(s))Ll&&console.log(g+this.stackID(B)+" (via recover-insert)"),this.advanceFully(B,t);this.stream.end>r.pos?(l==r.pos&&(l++,s=0),r.recoverByDelete(s,l),Ll&&console.log(g+this.stackID(r)+` (via recover-delete ${this.parser.getName(s)})`),DP(r,t)):(!n||n.score<C.score)&&(n=C)}return n}stackToTree(e){return e.close(),Pa.build({buffer:dk.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let A=(gk||(gk=new WeakMap)).get(e);return A||gk.set(e,A=String.fromCodePoint(this.nextStackID++)),A+e}};function DP(i,e){for(let A=0;A<e.length;A++){let t=e[A];if(t.pos==i.pos&&t.sameState(i)){e[A].score<i.score&&(e[A]=i);return}}e.push(i)}var uk=class{constructor(e,A,t){this.source=e,this.flags=A,this.disabled=t}allows(e){return!this.disabled||this.disabled[e]==0}};var z8=class i extends Ch{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let A=e.nodeNames.split(" ");this.minRepeatTerm=A.length;for(let r=0;r<e.repeatNodeCount;r++)A.push("");let t=Object.keys(e.topRules).map(r=>e.topRules[r][1]),n=[];for(let r=0;r<A.length;r++)n.push([]);function o(r,s,l){n[r].push([s,s.deserialize(String(l))])}if(e.nodeProps)for(let r of e.nodeProps){let s=r[0];typeof s=="string"&&(s=Hi[s]);for(let l=1;l<r.length;){let g=r[l++];if(g>=0)o(g,s,r[l++]);else{let C=r[l+-g];for(let d=-g;d>0;d--)o(r[l++],s,C);l++}}}this.nodeSet=new B4(A.map((r,s)=>ys.define({name:s>=this.minRepeatTerm?void 0:r,id:s,props:n[s],top:t.indexOf(s)>-1,error:s==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(s)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let a=M4(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let r=0;r<this.specializerSpecs.length;r++)this.specialized[r]=this.specializerSpecs[r].term;this.specializers=this.specializerSpecs.map(vP),this.states=M4(e.states,Uint32Array),this.data=M4(e.stateData),this.goto=M4(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(r=>typeof r=="number"?new L2(a,r):r),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,A,t){let n=new Qk(this,e,A,t);for(let o of this.wrappers)n=o(n,e,A,t);return n}getGoto(e,A,t=!1){let n=this.goto;if(A>=n[0])return-1;for(let o=n[A+1];;){let a=n[o++],r=a&1,s=n[o++];if(r&&t)return s;for(let l=o+(a>>1);o<l;o++)if(n[o]==e)return s;if(r)return-1}}hasAction(e,A){let t=this.data;for(let n=0;n<2;n++)for(let o=this.stateSlot(e,n?2:1),a;;o+=3){if((a=t[o])==65535)if(t[o+1]==1)a=t[o=CC(t,o+2)];else{if(t[o+1]==2)return CC(t,o+2);break}if(a==A||a==0)return CC(t,o+1)}return 0}stateSlot(e,A){return this.states[e*6+A]}stateFlag(e,A){return(this.stateSlot(e,0)&A)>0}validAction(e,A){return!!this.allActions(e,t=>t==A?!0:null)}allActions(e,A){let t=this.stateSlot(e,4),n=t?A(t):void 0;for(let o=this.stateSlot(e,1);n==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=CC(this.data,o+2);else break;n=A(CC(this.data,o+1))}return n}nextStates(e){let A=[];for(let t=this.stateSlot(e,1);;t+=3){if(this.data[t]==65535)if(this.data[t+1]==1)t=CC(this.data,t+2);else break;if((this.data[t+2]&1)==0){let n=this.data[t+1];A.some((o,a)=>a&1&&o==n)||A.push(this.data[t],n)}}return A}configure(e){let A=Object.assign(Object.create(i.prototype),this);if(e.props&&(A.nodeSet=this.nodeSet.extend(...e.props)),e.top){let t=this.topRules[e.top];if(!t)throw new RangeError(`Invalid top rule name ${e.top}`);A.top=t}return e.tokenizers&&(A.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(o=>o.from==t);return n?n.to:t})),e.specializers&&(A.specializers=this.specializers.slice(),A.specializerSpecs=this.specializerSpecs.map((t,n)=>{let o=e.specializers.find(r=>r.from==t.external);if(!o)return t;let a=Object.assign(Object.assign({},t),{external:o.to});return A.specializers[n]=vP(a),a})),e.contextTracker&&(A.context=e.contextTracker),e.dialect&&(A.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(A.strict=e.strict),e.wrap&&(A.wrappers=A.wrappers.concat(e.wrap)),e.bufferLength!=null&&(A.bufferLength=e.bufferLength),A}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let A=this.dynamicPrecedences;return A==null?0:A[e]||0}parseDialect(e){let A=Object.keys(this.dialects),t=A.map(()=>!1);if(e)for(let o of e.split(" ")){let a=A.indexOf(o);a>=0&&(t[a]=!0)}let n=null;for(let o=0;o<A.length;o++)if(!t[o])for(let a=this.dialects[A[o]],r;(r=this.data[a++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[r]=1;return new uk(e,t,n)}static deserialize(e){return new i(e)}};function CC(i,e){return i[e]|i[e+1]<<16}function Z2A(i){let e=null;for(let A of i){let t=A.p.stoppedAt;(A.pos==A.p.stream.end||t!=null&&A.pos>t)&&A.p.parser.stateFlag(A.state,2)&&(!e||e.score<A.score)&&(e=A)}return e}function vP(i){if(i.external){let e=i.extend?1:0;return(A,t)=>i.external(A,t)<<1|e}return i.get}var X2A=M8({String:Oe.string,Number:Oe.number,"True False":Oe.bool,PropertyName:Oe.propertyName,Null:Oe.null,", :":Oe.separator,"[ ]":Oe.squareBracket,"{ }":Oe.brace}),MP=z8.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"\u26A0 JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[X2A],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});var $2A=S8.define({name:"json",parser:MP.configure({props:[VS.add({Object:qS({except:/^\s*\}/}),Array:qS({except:/^\s*\]/})}),w4.add({"Object Array":lz})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function SP(){return new k8($2A)}var kP=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i,K2=class{constructor(e,A,t=0,n=e.length,o,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(t,n),this.bufferStart=t,this.normalize=o?r=>o(kP(r)):kP,this.query=this.normalize(A)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $r(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let A=qu(e),t=this.bufferStart+this.bufferPos;this.bufferPos+=Rl(e);let n=this.normalize(A);if(n.length)for(let o=0,a=t;;o++){let r=n.charCodeAt(o),s=this.match(r,a,this.bufferPos+this.bufferStart);if(o==n.length-1){if(s)return this.value=s,this;break}a==t&&o<A.length&&A.charCodeAt(o)==r&&a++}}}match(e,A,t){let n=null;for(let o=0;o<this.matches.length;o+=2){let a=this.matches[o],r=!1;this.query.charCodeAt(a)==e&&(a==this.query.length-1?n={from:this.matches[o+1],to:t}:(this.matches[o]++,r=!0)),r||(this.matches.splice(o,2),o-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?n={from:A,to:t}:this.matches.push(1,A)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}};typeof Symbol<"u"&&(K2.prototype[Symbol.iterator]=function(){return this});var RP={from:-1,to:-1,match:/.*/.exec("")},vk="gm"+(/x/.unicode==null?"":"u"),V8=class{constructor(e,A,t,n=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=RP,/\\[sWDnr]|\n|\r|\[\^/.test(A))return new W8(e,A,t,n,o);this.re=new RegExp(A,vk+(t?.ignoreCase?"i":"")),this.test=t?.test,this.iter=e.iter();let a=e.lineAt(n);this.curLineStart=a.from,this.matchPos=Z8(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let A=this.matchPos<=this.to&&this.re.exec(this.curLine);if(A){let t=this.curLineStart+A.index,n=t+A[0].length;if(this.matchPos=Z8(this.text,n+(t==n?1:0)),t==this.curLineStart+this.curLine.length&&this.nextLine(),(t<n||t>this.value.to)&&(!this.test||this.test(t,n,A)))return this.value={from:t,to:n,match:A},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},pk=new WeakMap,q8=class i{constructor(e,A){this.from=e,this.text=A}get to(){return this.from+this.text.length}static get(e,A,t){let n=pk.get(e);if(!n||n.from>=t||n.to<=A){let r=new i(A,e.sliceString(A,t));return pk.set(e,r),r}if(n.from==A&&n.to==t)return n;let{text:o,from:a}=n;return a>A&&(o=e.sliceString(A,a)+o,a=A),n.to<t&&(o+=e.sliceString(n.to,t)),pk.set(e,new i(a,o)),new i(A,o.slice(A-a,t-a))}},W8=class{constructor(e,A,t,n,o){this.text=e,this.to=o,this.done=!1,this.value=RP,this.matchPos=Z8(e,n),this.re=new RegExp(A,vk+(t?.ignoreCase?"i":"")),this.test=t?.test,this.flat=q8.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,A=this.re.exec(this.flat.text);if(A&&!A[0]&&A.index==e&&(this.re.lastIndex=e+1,A=this.re.exec(this.flat.text)),A){let t=this.flat.from+A.index,n=t+A[0].length;if((this.flat.to>=this.to||A.index+A[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,n,A)))return this.value={from:t,to:n,match:A},this.matchPos=Z8(this.text,n+(t==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=q8.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(V8.prototype[Symbol.iterator]=W8.prototype[Symbol.iterator]=function(){return this});function A1A(i){try{return new RegExp(i,vk),!0}catch(e){return!1}}function Z8(i,e){if(e>=i.length)return e;let A=i.lineAt(e),t;for(;e<A.to&&(t=A.text.charCodeAt(e-A.from))>=56320&&t<57344;)e++;return e}var e1A=i=>{let{state:e}=i,A=String(e.doc.lineAt(i.state.selection.main.head).number),{close:t,result:n}=GH(i,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:A},focus:!0,submitLabel:e.phrase("go")});return n.then(o=>{let a=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!a){i.dispatch({effects:t});return}let r=e.doc.lineAt(e.selection.main.head),[,s,l,g,C]=a,d=g?+g.slice(1):0,B=l?+l:r.number;if(l&&C){let f=B/100;s&&(f=f*(s=="-"?-1:1)+r.number/e.doc.lines),B=Math.round(e.doc.lines*f)}else l&&s&&(B=B*(s=="-"?-1:1)+r.number);let u=e.doc.line(Math.max(1,Math.min(e.doc.lines,B))),E=Be.cursor(u.from+Math.max(0,Math.min(d,u.length)));i.dispatch({effects:[t,ui.scrollIntoView(E.from,{y:"center"})],selection:E})}),!0},t1A={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},NP=nt.define({combine(i){return Lr(i,t1A,{highlightWordAroundCursor:(e,A)=>e||A,minSelectionLength:Math.min,maxMatches:Math.min})}});function FP(i){let e=[r1A,a1A];return i&&e.push(NP.of(i)),e}var i1A=Lt.mark({class:"cm-selectionMatch"}),n1A=Lt.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function _P(i,e,A,t){return(A==0||i(e.sliceDoc(A-1,A))!=$o.Word)&&(t==e.doc.length||i(e.sliceDoc(t,t+1))!=$o.Word)}function o1A(i,e,A,t){return i(e.sliceDoc(A,A+1))==$o.Word&&i(e.sliceDoc(t-1,t))==$o.Word}var a1A=Po.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(NP),{state:A}=i,t=A.selection;if(t.ranges.length>1)return Lt.none;let n=t.main,o,a=null;if(n.empty){if(!e.highlightWordAroundCursor)return Lt.none;let s=A.wordAt(n.head);if(!s)return Lt.none;a=A.charCategorizer(n.head),o=A.sliceDoc(s.from,s.to)}else{let s=n.to-n.from;if(s<e.minSelectionLength||s>200)return Lt.none;if(e.wholeWords){if(o=A.sliceDoc(n.from,n.to),a=A.charCategorizer(n.head),!(_P(a,A,n.from,n.to)&&o1A(a,A,n.from,n.to)))return Lt.none}else if(o=A.sliceDoc(n.from,n.to),!o)return Lt.none}let r=[];for(let s of i.visibleRanges){let l=new K2(A.doc,o,s.from,s.to);for(;!l.next().done;){let{from:g,to:C}=l.value;if((!a||_P(a,A,g,C))&&(n.empty&&g<=n.from&&C>=n.to?r.push(n1A.range(g,C)):(g>=n.to||C<=n.from)&&r.push(i1A.range(g,C)),r.length>e.maxMatches))return Lt.none}}return Lt.set(r)}},{decorations:i=>i.decorations}),r1A=ui.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),s1A=({state:i,dispatch:e})=>{let{selection:A}=i,t=Be.create(A.ranges.map(n=>i.wordAt(n.head)||Be.cursor(n.head)),A.mainIndex);return t.eq(A)?!1:(e(i.update({selection:t})),!0)};function l1A(i,e){let{main:A,ranges:t}=i.selection,n=i.wordAt(A.head),o=n&&n.from==A.from&&n.to==A.to;for(let a=!1,r=new K2(i.doc,e,t[t.length-1].to);;)if(r.next(),r.done){if(a)return null;r=new K2(i.doc,e,0,Math.max(0,t[t.length-1].from-1)),a=!0}else{if(a&&t.some(s=>s.from==r.value.from))continue;if(o){let s=i.wordAt(r.value.from);if(!s||s.from!=r.value.from||s.to!=r.value.to)continue}return r.value}}var g1A=({state:i,dispatch:e})=>{let{ranges:A}=i.selection;if(A.some(o=>o.from===o.to))return s1A({state:i,dispatch:e});let t=i.sliceDoc(A[0].from,A[0].to);if(i.selection.ranges.some(o=>i.sliceDoc(o.from,o.to)!=t))return!1;let n=l1A(i,t);return n?(e(i.update({selection:i.selection.addRange(Be.range(n.from,n.to),!1),effects:ui.scrollIntoView(n.to)})),!0):!1},Fd=nt.define({combine(i){return Lr(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new yk(e),scrollToMatch:e=>ui.scrollIntoView(e)})}});function LP(i){return i?[Fd.of(i),Dk]:Dk}var X8=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||A1A(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(A,t)=>t=="n"?` |