modscape 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,7 +48,7 @@ Error generating stack: `+p.message+`
|
|
|
48
48
|
`&&t.lineWrapping&&(i&&(i=de.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:tt.of([" "])}),n)return gC(t,n,i,o);if(i&&!Hd(i,s)){let c=!1,u="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(c=!0),u=t.inputState.lastSelectionOrigin,u=="select.pointer"&&(i=E6(r.facet(Uu).map(h=>h(t)),i))),t.dispatch({selection:i,scrollIntoView:c,userEvent:u}),!0}else return!1}function gC(t,e,n,i=-1){if(Ce.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Ce.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&sl(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&sl(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&sl(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,c=()=>o||(o=Zee(t,e,n));return t.state.facet(g6).some(u=>u(t,e.from,e.to,s,c))||t.dispatch(c()),!0}function Zee(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let u=e.from<s.from?-1:1,h=u<0?s.from:s.to,d=Kc(r.facet(Uu).map(m=>m(t)),h,u);e.from==d&&(o=d)}if(o>-1)i={changes:e,selection:de.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let u=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(u+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let u=r.changes(e),h=n&&n.main.to<=u.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let d=t.state.sliceDoc(e.from,e.to),m,g=n&&O6(t,n.main.head);if(g){let x=e.insert.length-(e.to-e.from);m={from:g.from,to:g.to-x}}else m=t.state.doc.lineAt(s.head);let y=s.to-e.to;i=r.changeByRange(x=>{if(x.from==s.from&&x.to==s.to)return{changes:u,range:h||x.map(u)};let w=x.to-y,S=w-d.length;if(t.state.sliceDoc(S,w)!=d||w>=m.from&&S<=m.to)return{range:x};let C=r.changes({from:S,to:w,insert:e.insert}),A=x.to-s.to;return{changes:C,range:h?de.range(Math.max(0,h.anchor+A),Math.max(0,h.head+A)):x.map(C)}})}else i={changes:u,selection:h&&r.selection.replaceRange(h)}}let c="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,c+=".compose",t.inputState.compositionFirstChange&&(c+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:c,scrollIntoView:!0})}function R6(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,c=e.length;for(;o>0&&c>0&&t.charCodeAt(o-1)==e.charCodeAt(c-1);)o--,c--;if(i=="end"){let u=Math.max(0,s-Math.min(o,c));n-=o+u-s}if(o<s&&t.length<e.length){let u=n<=s&&n>=o?s-n:0;s-=u,c=s+(c-o),o=s}else if(c<s){let u=n<=s&&n>=c?s-n:0;s-=u,o=s+(o-c),c=s}return{from:s,toA:o,toB:c}}function Jee(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new X3(n,i)),(r!=n||s!=i)&&e.push(new X3(r,s))),e}function ete(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?de.single(n+e,i+e):null}function Hd(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class tte{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.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,Ce.safari&&e.contentDOM.addEventListener("input",()=>null),Ce.gecko&>e(e.contentDOM.ownerDocument)}handleEvent(e){!cte(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,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=nte(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,c=i[s];c&&o!=!c.handlers.length&&(r.removeEventListener(s,this.handleEvent),c=null),c||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}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&&D6.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ce.android&&Ce.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return Ce.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=N6.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||ite.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,sl(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ce.safari&&!Ce.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 W3(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Fn(n.state,r)}}}function nte(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let c in s){let u=s[c];u&&n(c).handlers.push(W3(i.value,u))}if(o)for(let c in o){let u=o[c];u&&n(c).observers.push(W3(i.value,u))}}for(let i in Ii)n(i).handlers.push(Ii[i]);for(let i in Qn)n(i).observers.push(Qn[i]);return e}const N6=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ite="dthko",D6=[16,17,18,20,91,92,224,225],Bh=6;function qh(t){return Math.max(0,t)*.7+8}function rte(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class ste{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=n6(e.contentDOM),this.atoms=e.state.facet(Uu).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Je.allowMultipleSelections)&&ate(e,n),this.dragging=lte(e,n)&&B6(n)==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&&rte(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,c=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:c}=this.scrollParents.y.getBoundingClientRect());let u=mC(this.view);e.clientX-u.left<=r+Bh?n=-qh(r-e.clientX):e.clientX+u.right>=o-Bh&&(n=qh(e.clientX-o)),e.clientY-u.top<=s+Bh?i=-qh(s-e.clientY):e.clientY+u.bottom>=c-Bh&&(i=qh(e.clientY-c)),this.setScrollSpeed(n,i)}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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=E6(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function ate(t,e){let n=t.state.facet(h6);return n.length?n[0](e):Ce.mac?e.metaKey:e.ctrlKey}function ote(t,e){let n=t.state.facet(d6);return n.length?n[0](e):Ce.mac?!e.altKey:!e.ctrlKey}function lte(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=gu(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function cte(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Lt.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Ii=Object.create(null),Qn=Object.create(null),L6=Ce.ie&&Ce.ie_version<15||Ce.ios&&Ce.webkit_version<604;function ute(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),z6(t,n.value)},50)}function Pp(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function z6(t,e){e=Pp(t.state,fC,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(qS!=null&&n.selection.ranges.every(u=>u.empty)&&qS==s.toString()){let u=-1;i=n.changeByRange(h=>{let d=n.doc.lineAt(h.from);if(d.from==u)return{range:h};u=d.from;let m=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:d.from,insert:m},range:de.cursor(h.from+m.length)}})}else o?i=n.changeByRange(u=>{let h=s.line(r++);return{changes:{from:u.from,to:u.to,insert:h.text},range:de.cursor(u.from+h.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Qn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Qn.wheel=Qn.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ii.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Qn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};Qn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Ii.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(p6))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=hte(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new ste(t,e,n,i)),i&&t.observer.ignore(()=>{i6(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function K3(t,e,n,i){if(i==1)return de.cursor(e,n);if(i==2)return Uee(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,c=r?r.posAtEnd:s.to;return c<t.state.doc.length&&c==s.to&&c++,de.range(o,c)}}const fte=Ce.ie&&Ce.ie_version<=11;let Z3=null,J3=0,e5=0;function B6(t){if(!fte)return t.detail;let e=Z3,n=e5;return Z3=t,e5=Date.now(),J3=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(J3+1)%3:1}function hte(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=B6(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,c){let u=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,d=K3(t,u.pos,u.assoc,i);if(n.pos!=u.pos&&!o){let m=K3(t,n.pos,n.assoc,i),g=Math.min(m.from,d.from),y=Math.max(m.to,d.to);d=g<d.from?de.range(g,y):de.range(y,g)}return o?r.replaceRange(r.main.extend(d.from,d.to)):c&&i==1&&r.ranges.length>1&&(h=dte(r,u.pos))?h:c?r.addRange(d):de.create([d])}}}function dte(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return de.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Ii.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=de.range(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Pp(t.state,hC,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ii.dragend=t=>(t.inputState.draggedContent=null,!1);function t5(t,e,n,i){if(n=Pp(t.state,fC,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&ote(t,e)?{from:s.from,to:s.to}:null,c={from:r,insert:n},u=t.state.changes(o?[o,c]:c);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(r,-1),head:u.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ii.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&t5(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let c=new FileReader;c.onerror=s,c.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(i[o]=c.result),s()},c.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return t5(t,e,i,!0),!0}return!1};Ii.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=L6?null:e.clipboardData;return n?(z6(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(ute(t),!1)};function pte(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function mte(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Pp(t,hC,e.join(t.lineBreak)),ranges:n,linewise:i}}let qS=null;Ii.copy=Ii.cut=(t,e)=>{if(!Qc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=mte(t.state);if(!n&&!r)return!1;qS=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=L6?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(pte(t,n),!1)};const q6=dr.define();function j6(t,e){let n=[];for(let i of t.facet(y6)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:q6.of(!0)}):null}function I6(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=j6(t.state,e);n?t.dispatch(n):t.update([])}},10)}Qn.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),I6(t)};Qn.blur=t=>{t.observer.clearSelectionRange(),I6(t)};Qn.compositionstart=Qn.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Qn.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Ce.chrome&&Ce.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Qn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ii.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let c=o[0],u=t.posAtDOM(c.startContainer,c.startOffset),h=t.posAtDOM(c.endContainer,c.endOffset);return gC(t,{from:u,to:h,insert:t.state.toText(s)},null),!0}}let r;if(Ce.chrome&&Ce.android&&(r=N6.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Ce.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ce.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Qn.compositionend(t,e),20),!1};const n5=new Set;function gte(t){n5.has(t)||(n5.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const i5=["pre-wrap","normal","pre-line","break-spaces"];let yl=!1;function r5(){yl=!1}class yte{constructor(e){this.lineWrapping=e,this.doc=tt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 i5.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,i,r,s,o){let c=i5.indexOf(e)>-1,u=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=c||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=c,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,u){this.heightSamples={};for(let h=0;h<o.length;h++){let d=o[h];d<0?h++:this.heightSamples[Math.floor(d*10)]=!0}}return u}}class vte{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class Li{constructor(e,n,i,r,s){this.from=e,this.length=n,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?bn.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 Ua?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Li(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var xt=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(xt||(xt={}));const ld=.001;class Nn{constructor(e,n,i=2){this.length=e,this.height=n,this.flags=i}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)>ld&&(yl=!0),this.height=e)}replace(e,n,i){return Nn.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let c=r.length-1;c>=0;c--){let{fromA:u,toA:h,fromB:d,toB:m}=r[c],g=s.lineAt(u,xt.ByPosNoHeight,i.setDoc(n),0,0),y=g.to>=h?g:s.lineAt(h,xt.ByPosNoHeight,i,0,0);for(m+=y.to-h,h=y.to;c>0&&g.from<=r[c-1].toA;)u=r[c-1].fromA,d=r[c-1].fromB,c--,u<g.from&&(g=s.lineAt(u,xt.ByPosNoHeight,i,0,0));d+=g.from-u,u=g.from;let x=yC.build(i.setDoc(o),e,d,m);s=Ud(s,s.replace(u,h,x))}return s.updateHeight(i,0)}static empty(){return new ai(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,i=e.length,r=0,s=0;for(;;)if(n==i)if(r>s*2){let c=e[n-1];c.break?e.splice(--n,1,c.left,null,c.right):e.splice(--n,1,c.left,c.right),i+=1+c.break,r-=c.size}else if(s>r*2){let c=e[i];c.break?e.splice(i,1,c.left,null,c.right):e.splice(i,1,c.left,c.right),i+=2+c.break,s-=c.size}else break;else if(r<s){let c=e[n++];c&&(r+=c.size)}else{let c=e[--i];c&&(s+=c.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,i++),new xte(Nn.of(e.slice(0,n)),o,Nn.of(e.slice(i)))}}function Ud(t,e){return t==e?t:(t.constructor!=e.constructor&&(yl=!0),e)}Nn.prototype.size=1;const bte=Le.replace({});class P6 extends Nn{constructor(e,n,i){super(e,n),this.deco=i,this.spaceAbove=0}mainBlock(e,n){return new Li(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new Li(r,0,i,this.spaceAbove,bte):this.mainBlock(i,r)}lineAt(e,n,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,n,i,r,s,o){e<=s+this.length&&n>=s&&o(this.lineAt(0,xt.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ai extends P6{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new Li(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof ai||r instanceof gn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof gn?r=new ai(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Nn.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||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:""})`}}class gn extends Nn{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,c=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*s);o=u/s,this.length>s+1&&(c=(this.height-u)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:c}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:c,perChar:u}=this.heightMetrics(n,r);if(n.lineWrapping){let h=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),d=n.doc.lineAt(h),m=c+d.length*u,g=Math.max(i,e-m/2);return new Li(d.from,d.length,g,m,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/c))),{from:d,length:m}=n.doc.line(s+h);return new Li(d,m,i+c*h,c,0)}}lineAt(e,n,i,r,s){if(n==xt.ByHeight)return this.blockAt(e,i,r,s);if(n==xt.ByPosNoHeight){let{from:y,to:x}=i.doc.lineAt(e);return new Li(y,x-y,0,0,0)}let{firstLine:o,perLine:c,perChar:u}=this.heightMetrics(i,s),h=i.doc.lineAt(e),d=c+h.length*u,m=h.number-o,g=r+c*m+u*(h.from-s-m);return new Li(h.from,h.length,Math.max(r,Math.min(g,r+this.height-d)),d,0)}forEachLine(e,n,i,r,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:c,perLine:u,perChar:h}=this.heightMetrics(i,s);for(let d=e,m=r;d<=n;){let g=i.doc.lineAt(d);if(d==e){let x=g.number-c;m+=u*x+h*(e-s-x)}let y=u+h*g.length;o(new Li(g.from,g.length,m,y,0)),m+=y,d=g.to+1}}replace(e,n,i){let r=this.length-n;if(r>0){let s=i[i.length-1];s instanceof gn?i[i.length-1]=new gn(s.length+r):i.push(null,new gn(r-1))}if(e>0){let s=i[0];s instanceof gn?i[0]=new gn(e+s.length):i.unshift(new gn(e-1),null)}return Nn.of(i)}decomposeLeft(e,n){n.push(new gn(e-1),null)}decomposeRight(e,n){n.push(null,new gn(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],c=Math.max(n,r.from),u=-1;for(r.from>n&&o.push(new gn(r.from-n-1).updateHeight(e,n));c<=s&&r.more;){let d=e.doc.lineAt(c).length;o.length&&o.push(null);let m=r.heights[r.index++],g=0;m<0&&(g=-m,m=r.heights[r.index++]),u==-1?u=m:Math.abs(m-u)>=ld&&(u=-2);let y=new ai(d,m,g);y.outdated=!1,o.push(y),c+=d+1}c<=s&&o.push(null,new gn(s-c).updateHeight(e,c));let h=Nn.of(o);return(u<0||Math.abs(h.height-this.height)>=ld||Math.abs(u-this.heightMetrics(e,n).perLine)>=ld)&&(yl=!0),Ud(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class xte extends Nn{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,n,i,r):this.right.blockAt(e,n,s,r+this.left.length+this.break)}lineAt(e,n,i,r,s){let o=r+this.left.height,c=s+this.left.length+this.break,u=n==xt.ByHeight?e<o:e<c,h=u?this.left.lineAt(e,n,i,r,s):this.right.lineAt(e,n,i,o,c);if(this.break||(u?h.to<c:h.from>c))return h;let d=n==xt.ByPosNoHeight?xt.ByPosNoHeight:xt.ByPos;return u?h.join(this.right.lineAt(c,d,i,o,c)):this.left.lineAt(c,d,i,r,s).join(h)}forEachLine(e,n,i,r,s,o){let c=r+this.left.height,u=s+this.left.length+this.break;if(this.break)e<u&&this.left.forEachLine(e,n,i,r,s,o),n>=u&&this.right.forEachLine(e,n,i,c,u,o);else{let h=this.lineAt(u,xt.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=n&&o(h),n>h.to&&this.right.forEachLine(h.to+1,n,i,c,u,o)}}replace(e,n,i){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let c of i)s.push(c);if(e>0&&s5(s,o-1),n<this.length){let c=s.length;this.decomposeRight(n,s),s5(s,c)}return Nn.of(s)}decomposeLeft(e,n){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(i++,e>=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<i&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Nn.of(this.break?[e,null,n]:[e,n]):(this.left=Ud(this.left,e),this.right=Ud(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,c=n+s.length+this.break,u=null;return r&&r.from<=n+s.length&&r.more?u=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=c+o.length&&r.more?u=o=o.updateHeight(e,c,i,r):o.updateHeight(e,c,i),u?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function s5(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof gn&&(i=t[e+1])instanceof gn&&t.splice(e-1,3,new gn(n.length+1+i.length))}const wte=5;class yC{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ai?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ai(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e<n||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=n-e;i.block?this.addBlock(new P6(o,r,i)):(o||s||r>=wte)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,n);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:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,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 ai(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new gn(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ai)return e;let n=new ai(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof ai)&&!this.isCovered?this.nodes.push(new ai(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof ai&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,n,i,r){let s=new yC(i,e);return Ye.spans(n,i,r,s,0),s.finish(i)}}function Ste(t,e,n){let i=new Cte;return Ye.compare(t,e,n,i,0),i.changes}class Cte{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,i,r){(e<n||i&&i.heightRelevant||r&&r.heightRelevant)&&rl(e,n,this.changes,5)}}function kte(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),c=Math.max(0,n.top),u=Math.min(r.innerHeight,n.bottom);for(let h=t.parentNode;h&&h!=i.body;)if(h.nodeType==1){let d=h,m=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();s=Math.max(s,g.left),o=Math.min(o,g.right),c=Math.max(c,g.top),u=Math.min(h==t.parentNode?r.innerHeight:u,g.bottom)}h=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:c-(n.top+e),bottom:Math.max(c,u)-(n.top+e)}}function Ate(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function _te(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class cw{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,n){return Le.replace({widget:new Ote(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Ote extends mr{constructor(e,n){super(),this.size=e,this.vertical=n}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}}class a5{constructor(e,n){this.view=e,this.state=n,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=o5,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=yt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=n.facet(dC).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new yte(i),this.stateDeco=l5(n),this.heightMap=Nn.empty().applyChanges(this.stateDeco,tt.empty,this.heightOracle.setDoc(n.doc),[new Ci(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Le.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new jh(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?o5:new vC(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(Fc(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=l5(this.state);let r=e.changedRanges,s=Ci.extendWithRanges(r,Ste(i,this.stateDeco,e?e.changes:en.empty(this.state.doc.length))),o=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);r5(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||yl)&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<u.from||n.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,n));let h=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(b6)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?yt.RTL:yt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",c=n.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let h=0,d=0;if(c.width&&c.height){let{scaleX:T,scaleY:M}=t6(n,c);(T>.005&&Math.abs(this.scaleX-T)>.005||M>.005&&Math.abs(this.scaleY-M)>.005)&&(this.scaleX=T,this.scaleY=M,h|=16,o=u=!0)}let m=(parseInt(i.paddingTop)||0)*this.scaleY,g=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=m||this.paddingBottom!=g)&&(this.paddingTop=m,this.paddingBottom=g,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let y=n6(this.view.contentDOM,!1).y;y!=this.scrollParent&&(this.scrollParent=y,this.scrollAnchorHeight=-1,this.scrollOffset=0);let x=this.getScrollOffset();this.scrollOffset!=x&&(this.scrollAnchorHeight=-1,this.scrollOffset=x),this.scrolledToBottom=r6(this.scrollParent||e.win);let w=(this.printing?_te:kte)(n,this.paddingTop),S=w.top-this.pixelViewport.top,C=w.bottom-this.pixelViewport.bottom;this.pixelViewport=w;let A=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(A!=this.inView&&(this.inView=A,A&&(u=!0)),!this.inView&&!this.scrollTarget&&!Ate(e.dom))return 0;let O=c.width;if((this.contentDOMWidth!=O||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),u){let T=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(T)&&(o=!0),o||r.lineWrapping&&Math.abs(O-this.contentDOMWidth)>r.charWidth){let{lineHeight:M,charWidth:R,textHeight:z}=e.docView.measureTextSize();o=M>0&&r.refresh(s,M,R,z,Math.max(5,O/R),T),o&&(e.docView.minWidth=0,h|=16)}S>0&&C>0?d=Math.max(S,C):S<0&&C<0&&(d=Math.min(S,C)),r5();for(let M of this.viewports){let R=M.from==this.viewport.from?T:e.docView.measureVisibleLineHeights(M);this.heightMap=(o?Nn.empty().applyChanges(this.stateDeco,tt.empty,this.heightOracle,[new Ci(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new vte(M.from,R))}yl&&(h|=2)}let E=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),h|=this.updateForViewport()),(h&2||E)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:c}=this,u=new jh(r.lineAt(o-i*1e3,xt.ByHeight,s,0,0).from,r.lineAt(c+(1-i)*1e3,xt.ByHeight,s,0,0).to);if(n){let{head:h}=n.range;if(h<u.from||h>u.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),m=r.lineAt(h,xt.ByPos,s,0,0),g;n.y=="center"?g=(m.top+m.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&h<u.from?g=m.top:g=m.bottom-d,u=new jh(r.lineAt(g-1e3/2,xt.ByHeight,s,0,0).from,r.lineAt(g+d+1e3/2,xt.ByHeight,s,0,0).to)}}return u}mapViewport(e,n){let i=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new jh(this.heightMap.lineAt(i,xt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,xt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,xt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,xt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:c}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=c+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<c+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let i=[];for(let r of e)n.touchesRange(r.from,r.to)||i.push(new cw(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,n){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=yt.LTR&&!i)return[];let c=[],u=(d,m,g,y)=>{if(m-d<s)return;let x=this.state.selection.main,w=[x.from];x.empty||w.push(x.to);for(let C of w)if(C>d&&C<m){u(d,C-10,g,y),u(C+10,m,g,y);return}let S=Tte(e,C=>C.from>=g.from&&C.to<=g.to&&Math.abs(C.from-d)<s&&Math.abs(C.to-m)<s&&!w.some(A=>C.from<A&&C.to>A));if(!S){if(m<g.to&&n&&i&&n.visibleRanges.some(O=>O.from<=m&&O.to>=m)){let O=n.moveToLineBoundary(de.cursor(m),!1,!0).head;O>d&&(m=O)}let C=this.gapSize(g,d,m,y),A=i||C<2e6?C:2e6;S=new cw(d,m,C,A)}c.push(S)},h=d=>{if(d.length<o||d.type!=bn.Text)return;let m=Ete(d.from,d.to,this.stateDeco);if(m.total<o)return;let g=this.scrollTarget?this.scrollTarget.range.head:null,y,x;if(i){let w=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,S,C;if(g!=null){let A=Ph(m,g),O=((this.visibleBottom-this.visibleTop)/2+w)/d.height;S=A-O,C=A+O}else S=(this.visibleTop-d.top-w)/d.height,C=(this.visibleBottom-d.top+w)/d.height;y=Ih(m,S),x=Ih(m,C)}else{let w=m.total*this.heightOracle.charWidth,S=r*this.heightOracle.charWidth,C=0;if(w>2e6)for(let M of e)M.from>=d.from&&M.from<d.to&&M.size!=M.displaySize&&M.from*this.heightOracle.charWidth+C<this.pixelViewport.left&&(C=M.size-M.displaySize);let A=this.pixelViewport.left+C,O=this.pixelViewport.right+C,E,T;if(g!=null){let M=Ph(m,g),R=((O-A)/2+S)/w;E=M-R,T=M+R}else E=(A-S)/w,T=(O+S)/w;y=Ih(m,E),x=Ih(m,T)}y>d.from&&u(d.from,y,d,m),x<d.to&&u(x,d.to,d,m)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(h):h(d);return c}gapSize(e,n,i,r){let s=Ph(r,i)-Ph(r,n);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){cw.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Le.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];Ye.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],c=i[s];(o.from!=c.from||o.to!=c.to)&&(r|=4,e&&e.mapPos(o.from,-1)==c.from&&e.mapPos(o.to,1)==c.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Fc(this.heightMap.lineAt(e,xt.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(n=>n.top<=e&&n.bottom>=e)||Fc(this.heightMap.lineAt(this.scaler.fromDOM(e),xt.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 n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Fc(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}}class jh{constructor(e,n){this.from=e,this.to=n}}function Ete(t,e,n){let i=[],r=t,s=0;return Ye.spans(n,t,e,{span(){},point(o,c){o>r&&(i.push({from:r,to:o}),s+=o-r),r=c}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function Ih({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],c=o-s;if(i<=c)return s+i;i-=c}}function Ph(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function Tte(t,e){for(let n of t)if(e(n))return n}const o5={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function l5(t){let e=t.facet(qp).filter(i=>typeof i!="function"),n=t.facet(pC).filter(i=>typeof i!="function");return n.length&&e.push(Ye.join(n)),e}class vC{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:c,to:u})=>{let h=n.lineAt(c,xt.ByPos,e,0,0).top,d=n.lineAt(u,xt.ByPos,e,0,0).bottom;return r+=d-h,{from:c,to:u,top:h,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let c of this.viewports)c.domTop=o+(c.top-s)*this.scale,o=c.domBottom=c.domTop+(c.bottom-c.top),s=c.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof vC?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,i)=>n.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function Fc(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new Li(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>Fc(r,e)):t._content)}const Hh=ke.define({combine:t=>t.join(" ")}),jS=ke.define({combine:t=>t.indexOf(!0)>-1}),IS=Ys.newName(),H6=Ys.newName(),U6=Ys.newName(),V6={"&light":"."+H6,"&dark":"."+U6};function PS(t,e,n){return new Ys(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const Mte=PS("."+IS,{"&":{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-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"}},V6),Rte={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},uw=Ce.ie&&Ce.ie_version<=11;class Nte{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new lee,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(n=>{for(let i of n)this.queue.push(i);(Ce.ie&&Ce.ie_version<=11||Ce.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ce.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ce.chrome&&Ce.chrome_version<126)&&(this.editContext=new Lte(e),e.state.facet(Fr)&&(e.contentDOM.editContext=this.editContext.editContext)),uw&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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 n;((n=this.view.docView)===null||n===void 0?void 0:n.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(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Fr)?i.root.activeElement!=this.dom:!Qc(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Ce.ie&&Ce.ie_version<=11||Ce.android&&Ce.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Wc(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=gu(e.root);if(!n)return!1;let i=Ce.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Dte(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Qc(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&uee(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let i=this.dom;i;)if(i.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=n)i.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,Rte),uw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),uw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&sl(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.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 n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Qc(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Kee(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=M6(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!Hd(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=c5(n,e.previousSibling||e.target.previousSibling,-1),r=c5(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.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(Fr)!=e.state.facet(Fr)&&(e.view.contentDOM.editContext=e.state.facet(Fr)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.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 c5(t,e,n){for(;e;){let i=Lt.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function u5(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Wc(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function Dte(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return u5(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?u5(t,n):null}class Lte{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,c=this.toEditorPos(i.updateRangeStart),u=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:c,drifted:!1});let h=u-c>i.text.length;c==this.from&&s<this.from?c=s:u==this.to&&s>this.to&&(u=s);let d=R6(e.state.sliceDoc(c,u),i.text,(h?r.from:r.to)-c,h?"end":null);if(!d){let g=de.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Hd(g,r)||e.dispatch({selection:g,userEvent:"select"});return}let m={from:d.from+c,to:d.toA+c,insert:tt.of(i.text.slice(d.from,d.toB).split(`
|
|
49
49
|
`))};if((Ce.mac||Ce.android)&&m.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(m={from:c,to:u,insert:tt.of([i.text.replace("."," ")])}),this.pendingContextChange=m,!e.state.readOnly){let g=this.to-this.from+(m.to-m.from+m.insert.length);gC(e,m,de.single(this.toEditorPos(i.selectionStart,g),this.toEditorPos(i.selectionEnd,g)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),m.from<m.to&&!m.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),c=this.toEditorPos(i.rangeEnd);o<c;o++){let u=e.coordsForChar(o);s=u&&new DOMRect(u.left,u.top,u.right-u.left,u.bottom-u.top)||s||new DOMRect,r.push(s)}n.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,c=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(c)){let u=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(u<h){let d=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(c)?1:2}px`;r.push(Le.mark({attributes:{style:d}}).range(u,h))}}}e.dispatch({effects:w6.of(Le.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=gu(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,c,u,h)=>{if(i)return;let d=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,n+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=d,this.to+=d;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=d}n+=d}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Se{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cee(e.parent)||document,this.viewState=new a5(this,e.state||Je.create(e)),e.scrollTo&&e.scrollTo.is(zh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qo).map(r=>new rw(r));for(let r of this.plugins)r.update(this);this.observer=new Nte(this),this.inputState=new tte(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Y3(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Qt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let g of e){if(g.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=g.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,c=0,u=null;e.some(g=>g.annotation(q6))?(this.inputState.notifiedFocused=o,c=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=j6(s,o),u||(c=1));let h=this.observer.delayedAndroidKey,d=null;if(h?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Je.phrases)!=this.state.facet(Je.phrases))return this.setState(s);r=jd.create(this,s,e),r.flags|=c;let m=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(m&&(m=m.map(g.changes)),g.scrollIntoView){let{main:y}=g.state.selection;m=new al(y.empty?y:de.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of g.effects)y.is(zh)&&(m=y.value.clip(this.state))}this.viewState.update(r,m),this.bidiCache=Vd.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(Vc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Hh)!=r.state.facet(Hh)&&(this.viewState.mustMeasureContent=!0),(n||i||m||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let g of this.state.facet(DS))try{g(r)}catch(y){Fn(this.state,y,"update listener")}(u||d)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),d&&!M6(this,d)&&h.force&&sl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new a5(this,e),this.plugins=e.facet(Qo).map(i=>new rw(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Y3(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Qo),i=e.state.facet(Qo);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new rw(s));else{let c=this.plugins[o];c.mustUpdate=e,r.push(c)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(i){Fn(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let c=0;;c++){if(o<0)if(r6(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(r);s=y.from,o=y.top}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(c>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];u&4||([this.measureRequests,h]=[h,this.measureRequests]);let d=h.map(y=>{try{return y.read(this)}catch(x){return Fn(this.state,x),f5}}),m=jd.create(this,this.state,[]),g=!1;m.flags|=u,n?n.flags|=u:n=m,this.updateState=2,m.empty||(this.updatePlugins(m),this.inputState.update(m),this.updateAttrs(),g=this.docView.update(m),g&&this.docViewUpdate());for(let y=0;y<h.length;y++)if(d[y]!=f5)try{let x=h[y];x.write&&x.write(d[y],this)}catch(x){Fn(this.state,x)}if(g&&this.docView.updateSelection(!0),!m.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let x=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((x>1||x<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+x,i?i.scrollTop+=x:this.win.scrollBy(0,x),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let c of this.state.facet(DS))c(n)}get themeClasses(){return IS+" "+(this.state.facet(jS)?U6:H6)+" "+this.state.facet(Hh)}updateAttrs(){let e=h5(this,S6,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${Ce.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),h5(this,dC,n);let i=this.observer.ignore(()=>{let r=H3(this.contentDOM,this.contentAttrs,n),s=H3(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(Se.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Vc);let e=this.state.facet(Se.cspNonce);Ys.mount(this.root,this.styleModules.concat(Mte).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(i=>i.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,i){return lw(this,e,Q3(this,e,n,i))}moveByGroup(e,n){return lw(this,e,Q3(this,e,n,i=>$ee(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return de.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return Fee(this,e,n,i)}moveVertically(e,n,i){return lw(this,e,Gee(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=BS(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),BS(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.docView.coordsAt(e,n);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[sr.find(s,e-r.from,-1,n)];return yu(i,o.dir==yt.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(v6)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zte)return u6(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||c6(s.isolates,i=F3(this,e))))return s.order;i||(i=F3(this,e));let r=yee(e.text,n,i);return this.bidiCache.push(new Vd(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ce.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{i6(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return zh.of(new al(typeof e=="number"?de.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return zh.of(new al(de.cursor(i.from),"start","start",i.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return zt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return zt.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=Ys.newName(),r=[Hh.of(i),Vc.of(PS(`.${i}`,e))];return n&&n.dark&&r.push(jS.of(!0)),r}static baseTheme(e){return Za.lowest(Vc.of(PS("."+IS,e,V6)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&Lt.get(i)||Lt.get(e);return((n=r?.root)===null||n===void 0?void 0:n.view)||null}}Se.styleModule=Vc;Se.inputHandler=g6;Se.clipboardInputFilter=fC;Se.clipboardOutputFilter=hC;Se.scrollHandler=x6;Se.focusChangeEffect=y6;Se.perLineTextDirection=v6;Se.exceptionSink=m6;Se.updateListener=DS;Se.editable=Fr;Se.mouseSelectionStyle=p6;Se.dragMovesSelection=d6;Se.clickAddsSelectionRange=h6;Se.decorations=qp;Se.blockWrappers=C6;Se.outerDecorations=pC;Se.atomicRanges=Uu;Se.bidiIsolatedRanges=k6;Se.scrollMargins=A6;Se.darkTheme=jS;Se.cspNonce=ke.define({combine:t=>t.length?t[0]:""});Se.contentAttributes=dC;Se.editorAttributes=S6;Se.lineWrapping=Se.contentAttributes.of({class:"cm-lineWrapping"});Se.announce=je.define();const zte=4096,f5={};class Vd{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:yt.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!n.touchesRange(o.from,o.to)&&i.push(new Vd(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function h5(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&lC(o,n)}return n}const Bte=Ce.mac?"mac":Ce.windows?"win":Ce.linux?"linux":"key";function qte(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,c;for(let u=0;u<n.length-1;++u){const h=n[u];if(/^(cmd|meta|m)$/i.test(h))c=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?c=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),c&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Uh(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const jte=Za.default(Se.domEventHandlers({keydown(t,e){return $6(F6(e.state),t,e,"editor")}})),Hp=ke.define({enables:jte}),d5=new WeakMap;function F6(t){let e=t.facet(Hp),n=d5.get(e);return n||d5.set(e,n=Hte(e.reduce((i,r)=>i.concat(r),[]))),n}function Ite(t,e,n){return $6(F6(t.state),e,t,n)}let qs=null;const Pte=4e3;function Hte(t,e=Bte){let n=Object.create(null),i=Object.create(null),r=(o,c)=>{let u=i[o];if(u==null)i[o]=c;else if(u!=c)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,c,u,h,d)=>{var m,g;let y=n[o]||(n[o]=Object.create(null)),x=c.split(/ (?!$)/).map(C=>qte(C,e));for(let C=1;C<x.length;C++){let A=x.slice(0,C).join(" ");r(A,!0),y[A]||(y[A]={preventDefault:!0,stopPropagation:!1,run:[O=>{let E=qs={view:O,prefix:A,scope:o};return setTimeout(()=>{qs==E&&(qs=null)},Pte),!0}]})}let w=x.join(" ");r(w,!1);let S=y[w]||(y[w]={preventDefault:!1,stopPropagation:!1,run:((g=(m=y._any)===null||m===void 0?void 0:m.run)===null||g===void 0?void 0:g.slice())||[]});u&&S.run.push(u),h&&(S.preventDefault=!0),d&&(S.stopPropagation=!0)};for(let o of t){let c=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of c){let d=n[h]||(n[h]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:m}=o;for(let g in d)d[g].run.push(y=>m(y,HS))}let u=o[e]||o.key;if(u)for(let h of c)s(h,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return n}let HS=null;function $6(t,e,n,i){HS=e;let r=tee(e),s=In(r,0),o=ir(s)==r.length&&r!=" ",c="",u=!1,h=!1,d=!1;qs&&qs.view==n&&qs.scope==i&&(c=qs.prefix+" ",D6.indexOf(e.keyCode)<0&&(h=!0,qs=null));let m=new Set,g=S=>{if(S){for(let C of S.run)if(!m.has(C)&&(m.add(C),C(n)))return S.stopPropagation&&(d=!0),!0;S.preventDefault&&(S.stopPropagation&&(d=!0),h=!0)}return!1},y=t[i],x,w;return y&&(g(y[c+Uh(r,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ce.windows&&e.ctrlKey&&e.altKey)&&!(Ce.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=Qs[e.keyCode])&&x!=r?(g(y[c+Uh(x,e,!0)])||e.shiftKey&&(w=pu[e.keyCode])!=r&&w!=x&&g(y[c+Uh(w,e,!1)]))&&(u=!0):o&&e.shiftKey&&g(y[c+Uh(r,e,!0)])&&(u=!0),!u&&g(y._any)&&(u=!0)),h&&(u=!0),u&&d&&e.stopPropagation(),HS=null,u}class Vu{constructor(e,n,i,r,s){this.className=e,this.left=n,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=G6(e);return[new Vu(n,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Ute(e,n,i)}}function G6(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==yt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function p5(t,e,n,i){let r=t.coordsAtPos(e,n*2);if(!r)return i;let s=t.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,c=t.posAtCoords({x:s.left+1,y:o}),u=t.posAtCoords({x:s.right-1,y:o});return c==null||u==null?i:{from:Math.max(i.from,Math.min(c,u)),to:Math.min(i.to,Math.max(c,u))}}function Ute(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let i=Math.max(n.from,t.viewport.from),r=Math.min(n.to,t.viewport.to),s=t.textDirection==yt.LTR,o=t.contentDOM,c=o.getBoundingClientRect(),u=G6(t),h=o.querySelector(".cm-line"),d=h&&window.getComputedStyle(h),m=c.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),g=c.right-(d?parseInt(d.paddingRight):0),y=zS(t,i,1),x=zS(t,r,-1),w=y.type==bn.Text?y:null,S=x.type==bn.Text?x:null;if(w&&(t.lineWrapping||y.widgetLineBreaks)&&(w=p5(t,i,1,w)),S&&(t.lineWrapping||x.widgetLineBreaks)&&(S=p5(t,r,-1,S)),w&&S&&w.from==S.from&&w.to==S.to)return A(O(n.from,n.to,w));{let T=w?O(n.from,null,w):E(y,!1),M=S?O(null,n.to,S):E(x,!0),R=[];return(w||y).to<(S||x).from-(w&&S?1:0)||y.widgetLineBreaks>1&&T.bottom+t.defaultLineHeight/2<M.top?R.push(C(m,T.bottom,g,M.top)):T.bottom<M.top&&t.elementAtHeight((T.bottom+M.top)/2).type==bn.Text&&(T.bottom=M.top=(T.bottom+M.top)/2),A(T).concat(R).concat(A(M))}function C(T,M,R,z){return new Vu(e,T-u.left,M-u.top,Math.max(0,R-T),z-M)}function A({top:T,bottom:M,horizontal:R}){let z=[];for(let q=0;q<R.length;q+=2)z.push(C(R[q],T,R[q+1],M));return z}function O(T,M,R){let z=1e9,q=-1e9,U=[];function P(L,Y,D,Q,ee){let G=t.coordsAtPos(L,L==R.to?-2:2),W=t.coordsAtPos(D,D==R.from?2:-2);!G||!W||(z=Math.min(G.top,W.top,z),q=Math.max(G.bottom,W.bottom,q),ee==yt.LTR?U.push(s&&Y?m:G.left,s&&Q?g:W.right):U.push(!s&&Q?m:W.left,!s&&Y?g:G.right))}let $=T??R.from,K=M??R.to;for(let L of t.visibleRanges)if(L.to>$&&L.from<K)for(let Y=Math.max(L.from,$),D=Math.min(L.to,K);;){let Q=t.state.doc.lineAt(Y);for(let ee of t.bidiSpans(Q)){let G=ee.from+Q.from,W=ee.to+Q.from;if(G>=D)break;W>Y&&P(Math.max(G,Y),T==null&&G<=$,Math.min(W,D),M==null&&W>=K,ee.dir)}if(Y=Q.to+1,Y>=D)break}return U.length==0&&P($,T==null,K,M==null,t.textDirection),{top:z,bottom:q,horizontal:U}}function E(T,M){let R=c.top+(M?T.top:T.bottom);return{top:R,bottom:R,horizontal:[]}}}function Vte(t,e){return t.constructor==e.constructor&&t.eq(e)}class Fte{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(cd)!=e.state.facet(cd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,i=e.facet(cd);for(;n<i.length&&i[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,i)=>!Vte(n,this.drawn[i]))){let n=this.dom.firstChild,i=0;for(let r of e)r.update&&n&&r.constructor&&this.drawn[i].constructor&&r.update(n,this.drawn[i])?(n=n.nextSibling,i++):this.dom.insertBefore(r.draw(),n);for(;n;){let r=n.nextSibling;n.remove(),n=r}this.drawn=e,Ce.safari&&Ce.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const cd=ke.define();function Y6(t){return[zt.define(e=>new Fte(e,t)),cd.of(t)]}const bu=ke.define({combine(t){return pr(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function $te(t={}){return[bu.of(t),Gte,Yte,Qte,b6.of(!0)]}function Q6(t){return t.startState.facet(bu)!=t.state.facet(bu)}const Gte=Y6({above:!0,markers(t){let{state:e}=t,n=e.facet(bu),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||n.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=r.empty?r:de.cursor(r.head,r.head>r.anchor?-1:1);for(let u of Vu.forRange(t,o,c))i.push(u)}}return i},update(t,e){t.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Q6(t);return n&&m5(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){m5(e.state,t)},class:"cm-cursorLayer"});function m5(t,e){e.style.animationDuration=t.facet(bu).cursorBlinkRate+"ms"}const Yte=Y6({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Vu.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Q6(t)},class:"cm-selectionLayer"}),Qte=Za.highest(Se.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),X6=je.define({map(t,e){return t==null?null:e.mapPos(t)}}),$c=_n.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,i)=>i.is(X6)?i.value:n,t)}}),Xte=zt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field($c);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field($c)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field($c),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let i=t.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-i.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field($c)!=t&&this.view.dispatch({effects:X6.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Wte(){return[$c,Xte]}function g5(t,e,n,i,r){e.lastIndex=0;for(let s=t.iterRange(n,i),o=n,c;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;c=e.exec(s.value);)r(o+c.index,c)}function Kte(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class Zte{constructor(e){const{regexp:n,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,r)this.addMatch=(c,u,h,d)=>r(d,h,h+c[0].length,c,u);else if(typeof i=="function")this.addMatch=(c,u,h,d)=>{let m=i(c,u,h);m&&d(h,h+c[0].length,m)};else if(i)this.addMatch=(c,u,h,d)=>d(h,h+c[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let n=new Kr,i=n.add.bind(n);for(let{from:r,to:s}of Kte(e,this.maxLength))g5(e.state.doc,this.regexp,r,s,(o,c)=>this.addMatch(c,e,o,i));return n.finish()}updateDeco(e,n){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,c,u)=>{u>=e.view.viewport.from&&c<=e.view.viewport.to&&(i=Math.min(c,i),r=Math.max(u,r))}),e.viewportMoved||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,n.map(e.changes),i,r):n}updateRange(e,n,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),c=Math.min(s.to,r);if(c>=o){let u=e.state.doc.lineAt(o),h=u.to<c?e.state.doc.lineAt(c):u,d=Math.max(s.from,u.from),m=Math.min(s.to,h.to);if(this.boundary){for(;o>u.from;o--)if(this.boundary.test(u.text[o-1-u.from])){d=o;break}for(;c<h.to;c++)if(this.boundary.test(h.text[c-h.from])){m=c;break}}let g=[],y,x=(w,S,C)=>g.push(C.range(w,S));if(u==h)for(this.regexp.lastIndex=d-u.from;(y=this.regexp.exec(u.text))&&y.index<m-u.from;)this.addMatch(y,e,y.index+u.from,x);else g5(e.state.doc,this.regexp,d,m,(w,S)=>this.addMatch(S,e,w,x));n=n.update({filterFrom:d,filterTo:m,filter:(w,S)=>w<d||S>m,add:g})}}return n}}const US=/x/.unicode!=null?"gu":"g",Jte=new RegExp(`[\0-\b
|
|
50
50
|
--\u2028\u2029\uFEFF-]`,US),ene={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"};let fw=null;function tne(){var t;if(fw==null&&typeof document<"u"&&document.body){let e=document.body.style;fw=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return fw||!1}const ud=ke.define({combine(t){let e=pr(t,{render:null,specialChars:Jte,addSpecialChars:null});return(e.replaceTabs=!tne())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,US)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,US)),e}});function nne(t={}){return[ud.of(t),ine()]}let y5=null;function ine(){return y5||(y5=zt.fromClass(class{constructor(t){this.view=t,this.decorations=Le.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(ud)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Zte({regexp:t.specialChars,decoration:(e,n,i)=>{let{doc:r}=n.state,s=In(e[0],0);if(s==9){let o=r.lineAt(i),c=n.state.tabSize,u=Ol(o.text,c,i-o.from);return Le.replace({widget:new one((c-u%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Le.replace({widget:new ane(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(ud);t.startState.facet(ud)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const rne="•";function sne(t){return t>=32?rne:t==10?"":String.fromCharCode(9216+t)}class ane extends mr{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=sne(this.code),i=e.state.phrase("Control character")+" "+(ene[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class one extends mr{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 lne(){return une}const cne=Le.line({class:"cm-activeLine"}),une=zt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(cne.range(r.from)),e=r.from)}return Le.set(n)}},{decorations:t=>t.decorations});class fne extends mr{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?Xc(e.firstChild):[];if(!n.length)return null;let i=window.getComputedStyle(e.parentNode),r=yu(n[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function hne(t){let e=zt.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Le.set([Le.widget({widget:new fne(t),side:1}).range(0)]):Le.none}get decorations(){return this.view.state.doc.length?Le.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Se.contentAttributes.of({"aria-placeholder":t})]:e}const VS=2e3;function dne(t,e,n){let i=Math.min(e.line,n.line),r=Math.max(e.line,n.line),s=[];if(e.off>VS||n.off>VS||e.col<0||n.col<0){let o=Math.min(e.off,n.off),c=Math.max(e.off,n.off);for(let u=i;u<=r;u++){let h=t.doc.line(u);h.length<=c&&s.push(de.range(h.from+o,h.to+c))}}else{let o=Math.min(e.col,n.col),c=Math.max(e.col,n.col);for(let u=i;u<=r;u++){let h=t.doc.line(u),d=SS(h.text,o,t.tabSize,!0);if(d<0)s.push(de.cursor(h.to));else{let m=SS(h.text,c,t.tabSize);s.push(de.range(h.from+d,h.from+m))}}}return s}function pne(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function v5(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=t.state.doc.lineAt(n),r=n-i.from,s=r>VS?-1:r==i.length?pne(t,e.clientX):Ol(i.text,t.state.tabSize,n-i.from);return{line:i.number,col:s,off:r}}function mne(t,e){let n=v5(t,e),i=t.state.selection;return n?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(n.line).from),o=r.state.doc.lineAt(s);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},i=i.map(r.changes)}},get(r,s,o){let c=v5(t,r);if(!c)return i;let u=dne(t.state,n,c);return u.length?o?de.create(u.concat(i.ranges)):de.create(u):i}}:null}function gne(t){let e=(n=>n.altKey&&n.button==0);return Se.mouseSelectionStyle.of((n,i)=>e(i)?mne(n,i):null)}const yne={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},vne={style:"cursor: crosshair"};function bne(t={}){let[e,n]=yne[t.key||"Alt"],i=zt.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||n(r))},keyup(r){(r.keyCode==e||!n(r))&&this.set(!1)},mousemove(r){this.set(n(r))}}});return[i,Se.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?vne:null})]}const Vh="-10000px";class W6{constructor(e,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,n){var i;let r=e.state.facet(this.facet),s=r.filter(u=>u);if(r===this.input){for(let u of this.tooltipViews)u.update&&u.update(e);return!1}let o=[],c=n?[]:null;for(let u=0;u<s.length;u++){let h=s[u],d=-1;if(h){for(let m=0;m<this.tooltips.length;m++){let g=this.tooltips[m];g&&g.create==h.create&&(d=m)}if(d<0)o[u]=this.createTooltipView(h,u?o[u-1]:null),c&&(c[u]=!!h.above);else{let m=o[u]=this.tooltipViews[d];c&&(c[u]=n[d]),m.update&&m.update(e)}}}for(let u of this.tooltipViews)o.indexOf(u)<0&&(this.removeTooltipView(u),(i=u.destroy)===null||i===void 0||i.call(u));return n&&(c.forEach((u,h)=>n[h]=u),n.length=c.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function xne(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const hw=ke.define({combine:t=>{var e,n,i;return{position:Ce.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=t.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||xne}}}),b5=new WeakMap,bC=zt.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(hw);this.position=e.position,this.parent=e.parent,this.classes=t.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 W6(t,xC,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.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 t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(hw);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=Vh,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(t=i.destroy)===null||t===void 0||t.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ce.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=mC(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let c=this.manager.tooltipViews[o];return c.getCoords?c.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(hw).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let c=0;c<this.manager.tooltips.length;c++){let u=this.manager.tooltips[c],h=this.manager.tooltipViews[c],{dom:d}=h,m=t.pos[c],g=t.size[c];if(!m||u.clip!==!1&&(m.bottom<=Math.max(n.top,i.top)||m.top>=Math.min(n.bottom,i.bottom)||m.right<Math.max(n.left,i.left)-.1||m.left>Math.min(n.right,i.right)+.1)){d.style.top=Vh;continue}let y=u.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,x=y?7:0,w=g.right-g.left,S=(e=b5.get(h))!==null&&e!==void 0?e:g.bottom-g.top,C=h.offset||Sne,A=this.view.textDirection==yt.LTR,O=g.width>i.right-i.left?A?i.left:i.right-g.width:A?Math.max(i.left,Math.min(m.left-(y?14:0)+C.x,i.right-w)):Math.min(Math.max(i.left,m.left-w+(y?14:0)-C.x),i.right-w),E=this.above[c];!u.strictSide&&(E?m.top-S-x-C.y<i.top:m.bottom+S+x+C.y>i.bottom)&&E==i.bottom-m.bottom>m.top-i.top&&(E=this.above[c]=!E);let T=(E?m.top-i.top:i.bottom-m.bottom)-x;if(T<S&&h.resize!==!1){if(T<this.view.defaultLineHeight){d.style.top=Vh;continue}b5.set(h,S),d.style.height=(S=T)/s+"px"}else d.style.height&&(d.style.height="");let M=E?m.top-S-x-C.y:m.bottom+x+C.y,R=O+w;if(h.overlap!==!0)for(let z of o)z.left<R&&z.right>O&&z.top<M+S&&z.bottom>M&&(M=E?z.top-S-2-x:z.bottom+x+2);if(this.position=="absolute"?(d.style.top=(M-t.parent.top)/s+"px",x5(d,(O-t.parent.left)/r)):(d.style.top=M/s+"px",x5(d,O/r)),y){let z=m.left+(A?C.x:-C.x)-(O+14-7);y.style.left=z/r+"px"}h.overlap!==!0&&o.push({left:O,top:M,right:R,bottom:M+S}),d.classList.toggle("cm-tooltip-above",E),d.classList.toggle("cm-tooltip-below",!E),h.positioned&&h.positioned(t.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 t of this.manager.tooltipViews)t.dom.style.top=Vh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function x5(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const wne=Se.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"}}}),Sne={x:0,y:0},xC=ke.define({enables:[bC,wne]}),Fd=ke.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Up{static create(e){return new Up(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new W6(e,Fd,(n,i)=>this.createHostedView(n,i),n=>n.dom.remove())}createHostedView(e,n){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(n===void 0)n=r;else if(n!==r)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Cne=xC.compute([Fd],t=>{let e=t.facet(Fd);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var i;return(i=n.end)!==null&&i!==void 0?i:n.pos})),create:Up.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class kne{constructor(e,n,i,r,s){this.view=e,this.source=n,this.field=i,this.setHover=r,this.hoverTime=s,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:n}=this,i=e.docView.tile.nearest(n.target);if(!i)return;let r,s=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(n),r==null)return;let c=e.coordsAtPos(r);if(!c||n.y<c.top||n.y>c.bottom||n.x<c.left-e.defaultCharacterWidth||n.x>c.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(r)).find(d=>d.from<=r&&d.to>=r),h=u&&u.dir==yt.RTL?-1:1;s=n.x<c.left?-h:h}let o=this.source(e,r,s);if(o?.then){let c=this.pending={pos:r};o.then(u=>{this.pending==c&&(this.pending=null,u&&!(Array.isArray(u)&&!u.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(u)?u:[u])}))},u=>Fn(e.state,u,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(bC),n=e?e.manager.tooltips.findIndex(i=>i.create==Up.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,i;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:r,tooltip:s}=this;if(r.length&&s&&!Ane(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,c=(i=(n=r[0])===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:o;(o==c?this.view.posAtCoords(this.lastMove)!=o:!_ne(this.view,o,c,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=i=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Fh=4;function Ane(t,e){let{left:n,right:i,top:r,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let c=o.getBoundingClientRect();r=Math.min(c.top,r),s=Math.max(c.bottom,s)}return e.clientX>=n-Fh&&e.clientX<=i+Fh&&e.clientY>=r-Fh&&e.clientY<=s+Fh}function _ne(t,e,n,i,r,s){let o=t.scrollDOM.getBoundingClientRect(),c=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,c)<r)return!1;let u=t.posAtCoords({x:i,y:r},!1);return u>=e&&u<=n}function One(t,e={}){let n=je.define(),i=_n.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let c of r){let u=s.changes.mapPos(c.pos,-1,Rn.TrackDel);if(u!=null){let h=Object.assign(Object.create(null),c);h.pos=u,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}r=o}for(let o of s.effects)o.is(n)&&(r=o.value),o.is(Ene)&&(r=[]);return r},provide:r=>Fd.from(r)});return{active:i,extension:[i,zt.define(r=>new kne(r,t,i,n,e.hoverTime||300)),Cne]}}function K6(t,e){let n=t.plugin(bC);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}const Ene=je.define(),w5=ke.define({combine(t){let e,n;for(let i of t)e=e||i.topContainer,n=n||i.bottomContainer;return{topContainer:e,bottomContainer:n}}});function wC(t,e){let n=t.plugin(Z6),i=n?n.specs.indexOf(e):-1;return i>-1?n.panels[i]:null}const Z6=zt.fromClass(class{constructor(t){this.input=t.state.facet(xu),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(w5);this.top=new $h(t,!0,e.topContainer),this.bottom=new $h(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(w5);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new $h(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new $h(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(xu);if(n!=this.input){let i=n.filter(u=>u),r=[],s=[],o=[],c=[];for(let u of i){let h=this.specs.indexOf(u),d;h<0?(d=u(t.view),c.push(d)):(d=this.panels[h],d.update&&d.update(t)),r.push(d),(d.top?s:o).push(d)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let u of c)u.dom.classList.add("cm-panel"),u.mount&&u.mount()}else for(let i of this.panels)i.update&&i.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Se.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class $h{constructor(e,n,i){this.view=e,this.top=n,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.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 n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=S5(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=S5(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 S5(t){let e=t.nextSibling;return t.remove(),e}const xu=ke.define({enables:Z6});function Tne(t,e){let n,i=new Promise(o=>n=o),r=o=>Mne(o,e,n);t.state.field(dw,!1)?t.dispatch({effects:J6.of(r)}):t.dispatch({effects:je.appendConfig.of(dw.init(()=>[r]))});let s=eq.of(r);return{close:s,result:i.then(o=>((t.win.queueMicrotask||(u=>t.win.setTimeout(u,10)))(()=>{t.state.field(dw).indexOf(r)>-1&&t.dispatch({effects:s})}),o))}}const dw=_n.define({create(){return[]},update(t,e){for(let n of e.effects)n.is(J6)?t=[n.value].concat(t):n.is(eq)&&(t=t.filter(i=>i!=n.value));return t},provide:t=>xu.computeN([t],e=>e.field(t))}),J6=je.define(),eq=je.define();function Mne(t,e,n){let i=e.content?e.content(t,()=>o(null)):null;if(!i){if(i=dt("form"),e.input){let c=dt("input",e.input);/^(text|password|number|email|tel|url)$/.test(c.type)&&c.classList.add("cm-textfield"),c.name||(c.name="input"),i.appendChild(dt("label",(e.label||"")+": ",c))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(dt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let c=0;c<r.length;c++){let u=r[c];u.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(u))}),u.addEventListener("submit",h=>{h.preventDefault(),o(u)})}let s=dt("div",i,dt("button",{onclick:()=>o(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(c){s.contains(s.ownerDocument.activeElement)&&t.focus(),n(c)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let c;typeof e.focus=="string"?c=i.querySelector(e.focus):c=i.querySelector("input")||i.querySelector("button"),c&&"select"in c?c.select():c&&"focus"in c&&c.focus()}}}}class Jr extends Gs{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Jr.prototype.elementClass="";Jr.prototype.toDOM=void 0;Jr.prototype.mapMode=Rn.TrackBefore;Jr.prototype.startSide=Jr.prototype.endSide=-1;Jr.prototype.point=!0;const fd=ke.define(),Rne=ke.define(),Nne={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ye.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Zc=ke.define();function Dne(t){return[tq(),Zc.of({...Nne,...t})]}const C5=ke.define({combine:t=>t.some(e=>e)});function tq(t){return[Lne]}const Lne=zt.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Zc).map(e=>new A5(t,e)),this.fixed=!t.state.facet(C5);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.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(C5)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=Ye.iter(this.view.state.facet(fd),this.view.viewport.from),i=[],r=this.gutters.map(s=>new zne(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let c of s.type)if(c.type==bn.Text&&o){FS(n,i,c.from);for(let u of r)u.line(this.view,c,i);o=!1}else if(c.widget)for(let u of r)u.widget(this.view,c)}else if(s.type==bn.Text){FS(n,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Zc),n=t.state.facet(Zc),i=t.docChanged||t.heightChanged||t.viewportChanged||!Ye.eq(t.startState.facet(fd),t.state.facet(fd),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let r of this.gutters)r.update(t)&&(i=!0);else{i=!0;let r=[];for(let s of n){let o=e.indexOf(s);o<0?r.push(new A5(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Se.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==yt.LTR?{left:i,right:r}:{right:i,left:r}})});function k5(t){return Array.isArray(t)?t:[t]}function FS(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class zne{constructor(e,n,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Ye.iter(e.markers,n.from)}addElement(e,n,i){let{gutter:r}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==r.elements.length){let c=new nq(e,o,s,i);r.elements.push(c),r.dom.appendChild(c.dom)}else r.elements[this.i].update(e,o,s,i);this.height=n.bottom,this.i++}line(e,n,i){let r=[];FS(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,n,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,r)}widget(e,n){let i=this.gutter.config.widgetMarker(e,n.widget,n),r=i?[i]:null;for(let s of e.state.facet(Rne)){let o=s(e,n.widget,n);o&&(r||(r=[])).push(o)}r&&this.addElement(e,n,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class A5{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let u=s.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=r.clientY;let c=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[i](e,c,r)&&r.preventDefault()});this.markers=k5(n.markers(e)),n.initialSpacer&&(this.spacer=new nq(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=k5(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!Ye.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class nq{constructor(e,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,i,r)}update(e,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Bne(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let c=o,u=s<n.length?n[s++]:null,h=!1;if(u){let d=u.elementClass;d&&(i+=" "+d);for(let m=o;m<this.markers.length;m++)if(this.markers[m].compare(u)){c=m,h=!0;break}}else c=this.markers.length;for(;o<c;){let d=this.markers[o++];if(d.toDOM){d.destroy(r);let m=r.nextSibling;r.remove(),r=m}}if(!u)break;u.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(u.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=n}destroy(){this.setMarkers(null,[])}}function Bne(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const qne=ke.define(),jne=ke.define(),Xo=ke.define({combine(t){return pr(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let i=Object.assign({},e);for(let r in n){let s=i[r],o=n[r];i[r]=s?(c,u,h)=>s(c,u,h)||o(c,u,h):o}return i}})}});class pw extends Jr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function mw(t,e){return t.state.facet(Xo).formatNumber(e,t.state)}const Ine=Zc.compute([Xo],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(qne)},lineMarker(e,n,i){return i.some(r=>r.toDOM)?null:new pw(mw(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,i)=>{for(let r of e.state.facet(jne)){let s=r(e,n,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Xo)!=e.state.facet(Xo),initialSpacer(e){return new pw(mw(e,_5(e.state.doc.lines)))},updateSpacer(e,n){let i=mw(n.view,_5(n.view.state.doc.lines));return i==e.number?e:new pw(i)},domEventHandlers:t.facet(Xo).domEventHandlers,side:"before"}));function Pne(t={}){return[Xo.of(t),tq(),Ine]}function _5(t){let e=9;for(;e<t;)e=e*10+9;return e}const Hne=new class extends Jr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Une=fd.compute(["selection"],t=>{let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.head).from;r>n&&(n=r,e.push(Hne.range(r)))}return Ye.of(e)});function Vne(){return Une}const iq=1024;let Fne=0;class gw{constructor(e,n){this.from=e,this.to=n}}class Fe{constructor(e={}){this.id=Fne++,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=Xn.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}Fe.closedBy=new Fe({deserialize:t=>t.split(" ")});Fe.openedBy=new Fe({deserialize:t=>t.split(" ")});Fe.group=new Fe({deserialize:t=>t.split(" ")});Fe.isolate=new Fe({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Fe.contextHash=new Fe({perNode:!0});Fe.lookAhead=new Fe({perNode:!0});Fe.mounted=new Fe({perNode:!0});class Jc{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[Fe.mounted.id]}}const $ne=Object.create(null);class Xn{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):$ne,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Xn(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}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 n=this.prop(Fe.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(Fe.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}Xn.none=new Xn("",Object.create(null),0,8);class SC{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let c=o[1],u=o[0];u.combine&&u.id in r&&(c=u.combine(r[u.id],c)),r[u.id]=c}}n.push(r?new Xn(i.name,r,i.id,i.flags):i)}return new SC(n)}}const Gh=new WeakMap,O5=new WeakMap;var Nt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Nt||(Nt={}));class It{constructor(e,n,i,r,s){if(this.type=e,this.children=n,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,c]of s)this.props[typeof o=="number"?o:o.id]=c}}toString(){let e=Jc.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let i of this.children){let r=i.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new GS(this.topNode,e)}cursorAt(e,n=0,i=0){let r=Gh.get(this)||this.topNode,s=new GS(r);return s.moveTo(e,n),Gh.set(this,s._tree),s}get topNode(){return new _i(this,0,0,null)}resolve(e,n=0){let i=wu(Gh.get(this)||this.topNode,e,n,!1);return Gh.set(this,i),i}resolveInner(e,n=0){let i=wu(O5.get(this)||this.topNode,e,n,!0);return O5.set(this,i),i}resolveStack(e,n=0){return Qne(this,e,n)}iterate(e){let{enter:n,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,c=(o&Nt.IncludeAnonymous)>0;for(let u=this.cursor(o|Nt.IncludeAnonymous);;){let h=!1;if(u.from<=s&&u.to>=r&&(!c&&u.type.isAnonymous||n(u)!==!1)){if(u.firstChild())continue;h=!0}for(;h&&i&&(c||!u.type.isAnonymous)&&i(u),!u.nextSibling();){if(!u.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:AC(Xn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new It(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new It(Xn.none,n,i,r)))}static build(e){return Xne(e)}}It.empty=new It(Xn.none,[],[],0);class CC{constructor(e,n){this.buffer=e,this.index=n}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 CC(this.buffer,this.index)}}class Ws{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return Xn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],i=this.buffer[e+3],r=this.set.types[n],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,i,r,s){let{buffer:o}=this,c=-1;for(let u=e;u!=n&&!(rq(s,r,o[u+1],o[u+2])&&(c=u,i>0));u=o[u+3]);return c}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let c=e,u=0;c<n;){s[u++]=r[c++],s[u++]=r[c++]-i;let h=s[u++]=r[c++]-i;s[u++]=r[c++]-e,o=Math.max(o,h)}return new Ws(s,o,this.set)}}function rq(t,e,n,i){switch(t){case-2:return n<e;case-1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function wu(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!i&&t instanceof _i&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=i?0:Nt.IgnoreOverlays;if(i)for(let o=t,c=o.parent;c;o=c,c=o.parent)o instanceof _i&&o.index<0&&((r=c.enter(e,n,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=c);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class sq{cursor(e=0){return new GS(this,e)}getChild(e,n=null,i=null){let r=E5(this,e,n,i);return r.length?r[0]:null}getChildren(e,n=null,i=null){return E5(this,e,n,i)}resolve(e,n=0){return wu(this,e,n,!1)}resolveInner(e,n=0){return wu(this,e,n,!0)}matchContext(e){return $S(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),i=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(i=n,n=r.prevSibling):n=r}return i}get node(){return this}get next(){return this.parent}}class _i extends sq{constructor(e,n,i,r){super(),this._tree=e,this.from=n,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,i,r,s=0){for(let o=this;;){for(let{children:c,positions:u}=o._tree,h=n>0?c.length:-1;e!=h;e+=n){let d=c[e],m=u[e]+o.from,g;if(!(!(s&Nt.EnterBracketed&&d instanceof It&&(g=Jc.get(d))&&!g.overlay&&g.bracketed&&i>=m&&i<=m+d.length)&&!rq(r,i,m,m+d.length))){if(d instanceof Ws){if(s&Nt.ExcludeBuffers)continue;let y=d.findChild(0,d.buffer.length,n,i-m,r);if(y>-1)return new Is(new Gne(o,d,e,m),null,y)}else if(s&Nt.IncludeAnonymous||!d.type.isAnonymous||kC(d)){let y;if(!(s&Nt.IgnoreMounts)&&(y=Jc.get(d))&&!y.overlay)return new _i(y.tree,m,e,o);let x=new _i(d,m,e,o);return s&Nt.IncludeAnonymous||!x.type.isAnonymous?x:x.nextChild(n<0?d.children.length-1:0,n,i,r,s)}}}if(s&Nt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))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,n,i=0){let r;if(!(i&Nt.IgnoreOverlays)&&(r=Jc.get(this._tree))&&r.overlay){let s=e-this.from,o=i&Nt.EnterBracketed&&r.bracketed;for(let{from:c,to:u}of r.overlay)if((n>0||o?c<=s:c<s)&&(n<0||o?u>=s:u>s))return new _i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}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 E5(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function $S(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class Gne{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Is extends sq{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,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Is(this.context,this,s)}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,n,i=0){if(i&Nt.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Is(this.context,this,s)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Is(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Is(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new It(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function aq(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let i=n instanceof _i&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new Yne(r,n)}class Yne{constructor(e,n){this.heads=e,this.node=n}get next(){return aq(this.heads)}}function Qne(t,e,n){let i=t.resolveInner(e,n),r=null;for(let s=i instanceof _i?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,n)),s=o}else{let o=Jc.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let c=new _i(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(wu(c,e,n,!1))}}return r?aq(r):i}class GS{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Nt.EnterBracketed,e instanceof _i)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof _i?(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,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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,n,i=this.mode){return this.buffer?i&Nt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Nt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Nt.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:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<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 n,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:i}=r)}else({index:n,_parent:i}=this._tree);for(;i;{index:n,_parent:i}=i)if(n>-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let c=i._tree.children[s];if(this.mode&Nt.IncludeAnonymous||c instanceof Ws||!c.type.isAnonymous||kC(c))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)n=new Is(this.buffer,n,this.stack[r]);return this.bufferNode=new Is(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return $S(this.node.parent,e);let{buffer:n}=this.buffer,{types:i}=n.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return $S(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function kC(t){return t.children.some(e=>e instanceof Ws||!e.type.isAnonymous||kC(e))}function Xne(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=iq,reused:s=[],minRepeatType:o=i.types.length}=t,c=Array.isArray(n)?new CC(n,n.length):n,u=i.types,h=0,d=0;function m(T,M,R,z,q,U){let{id:P,start:$,end:K,size:L}=c,Y=d,D=h;if(L<0)if(c.next(),L==-1){let B=s[P];R.push(B),z.push($-T);return}else if(L==-3){h=P;return}else if(L==-4){d=P;return}else throw new RangeError(`Unrecognized record size: ${L}`);let Q=u[P],ee,G,W=$-T;if(K-$<=r&&(G=S(c.pos-M,q))){let B=new Uint16Array(G.size-G.skip),F=c.pos-G.size,ne=B.length;for(;c.pos>F;)ne=C(G.start,B,ne);ee=new Ws(B,K-G.start,i),W=G.start-T}else{let B=c.pos-L;c.next();let F=[],ne=[],I=P>=o?P:-1,X=0,J=K;for(;c.pos>B;)I>=0&&c.id==I&&c.size>=0?(c.end<=J-r&&(x(F,ne,$,X,c.end,J,I,Y,D),X=F.length,J=c.end),c.next()):U>2500?g($,B,F,ne):m($,B,F,ne,I,U+1);if(I>=0&&X>0&&X<F.length&&x(F,ne,$,X,$,J,I,Y,D),F.reverse(),ne.reverse(),I>-1&&X>0){let oe=y(Q,D);ee=AC(Q,F,ne,0,F.length,0,K-$,oe,oe)}else ee=w(Q,F,ne,K-$,Y-K,D)}R.push(ee),z.push(W)}function g(T,M,R,z){let q=[],U=0,P=-1;for(;c.pos>M;){let{id:$,start:K,end:L,size:Y}=c;if(Y>4)c.next();else{if(P>-1&&K<P)break;P<0&&(P=L-r),q.push($,K,L),U++,c.next()}}if(U){let $=new Uint16Array(U*4),K=q[q.length-2];for(let L=q.length-3,Y=0;L>=0;L-=3)$[Y++]=q[L],$[Y++]=q[L+1]-K,$[Y++]=q[L+2]-K,$[Y++]=Y;R.push(new Ws($,q[2]-K,i)),z.push(K-T)}}function y(T,M){return(R,z,q)=>{let U=0,P=R.length-1,$,K;if(P>=0&&($=R[P])instanceof It){if(!P&&$.type==T&&$.length==q)return $;(K=$.prop(Fe.lookAhead))&&(U=z[P]+$.length+K)}return w(T,R,z,q,U,M)}}function x(T,M,R,z,q,U,P,$,K){let L=[],Y=[];for(;T.length>z;)L.push(T.pop()),Y.push(M.pop()+R-q);T.push(w(i.types[P],L,Y,U-q,$-U,K)),M.push(q-R)}function w(T,M,R,z,q,U,P){if(U){let $=[Fe.contextHash,U];P=P?[$].concat(P):[$]}if(q>25){let $=[Fe.lookAhead,q];P=P?[$].concat(P):[$]}return new It(T,M,R,z,P)}function S(T,M){let R=c.fork(),z=0,q=0,U=0,P=R.end-r,$={size:0,start:0,skip:0};e:for(let K=R.pos-T;R.pos>K;){let L=R.size;if(R.id==M&&L>=0){$.size=z,$.start=q,$.skip=U,U+=4,z+=4,R.next();continue}let Y=R.pos-L;if(L<0||Y<K||R.start<P)break;let D=R.id>=o?4:0,Q=R.start;for(R.next();R.pos>Y;){if(R.size<0)if(R.size==-3||R.size==-4)D+=4;else break e;else R.id>=o&&(D+=4);R.next()}q=Q,z+=L,U+=D}return(M<0||z==T)&&($.size=z,$.start=q,$.skip=U),$.size>4?$:void 0}function C(T,M,R){let{id:z,start:q,end:U,size:P}=c;if(c.next(),P>=0&&z<o){let $=R;if(P>4){let K=c.pos-(P-4);for(;c.pos>K;)R=C(T,M,R)}M[--R]=$,M[--R]=U-T,M[--R]=q-T,M[--R]=z}else P==-3?h=z:P==-4&&(d=z);return R}let A=[],O=[];for(;c.pos>0;)m(t.start||0,t.bufferStart||0,A,O,-1,0);let E=(e=t.length)!==null&&e!==void 0?e:A.length?O[0]+A[0].length:0;return new It(u[t.topID],A.reverse(),O.reverse(),E)}const T5=new WeakMap;function hd(t,e){if(!t.isAnonymous||e instanceof Ws||e.type!=t)return 1;let n=T5.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof It)){n=1;break}n+=hd(t,i)}T5.set(e,n)}return n}function AC(t,e,n,i,r,s,o,c,u){let h=0;for(let x=i;x<r;x++)h+=hd(t,e[x]);let d=Math.ceil(h*1.5/8),m=[],g=[];function y(x,w,S,C,A){for(let O=S;O<C;){let E=O,T=w[O],M=hd(t,x[O]);for(O++;O<C;O++){let R=hd(t,x[O]);if(M+R>=d)break;M+=R}if(O==E+1){if(M>d){let R=x[E];y(R.children,R.positions,0,R.children.length,w[E]+A);continue}m.push(x[E])}else{let R=w[O-1]+x[O-1].length-T;m.push(AC(t,x,w,E,O,T,R,null,u))}g.push(T+A-s)}}return y(e,n,i,r,0),(c||u)(m,g,o)}class ja{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new ja(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let c=0,u=0,h=0;;c++){let d=c<n.length?n[c]:null,m=d?d.fromA:1e9;if(m-u>=i)for(;o&&o.from<m;){let g=o;if(u>=g.from||m<=g.to||h){let y=Math.max(g.from,u)-h,x=Math.min(g.to,m)-h;g=y>=x?null:new ja(y,x,g.tree,g.offset+h,c>0,!!d)}if(g&&r.push(g),o.to>m)break;o=s<e.length?e[s++]:null}if(!d)break;u=d.toA,h=d.toA-d.toB}return r}}class oq{startParse(e,n,i){return typeof e=="string"&&(e=new Wne(e)),i=i?i.length?i.map(r=>new gw(r.from,r.to)):[new gw(0,0)]:[new gw(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class Wne{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Fe({perNode:!0});let Kne=0,Ur=class YS{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=Kne++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof YS&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let r=new YS(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new $d(e);return i=>i.modified.indexOf(n)>-1?i:$d.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}},Zne=0;class $d{constructor(e){this.name=e,this.instances=[],this.id=Zne++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(c=>c.base==e&&Jne(n,c.modified));if(i)return i;let r=[],s=new Ur(e.name,r,e,n);for(let c of n)c.instances.push(s);let o=eie(n);for(let c of e.set)if(!c.modified.length)for(let u of o)r.push($d.get(c,u));return s}}function Jne(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function eie(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((n,i)=>i.length-n.length)}function lq(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,c=r;for(let m=0;;){if(c=="..."&&m>0&&m+3==r.length){o=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!g)throw new RangeError("Invalid path: "+r);if(s.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),m+=g[0].length,m==r.length)break;let y=r[m++];if(m==r.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+r);c=r.slice(m)}let u=s.length-1,h=s[u];if(!h)throw new RangeError("Invalid path: "+r);let d=new Su(i,o,u>0?s.slice(0,u):null);e[h]=d.sort(e[h])}}return cq.add(e)}const cq=new Fe({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Su(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Su{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,this.next=r}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}}Su.empty=new Su([],2,null);function uq(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let c of s)for(let u of c.set){let h=n[u.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function tie(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function nie(t,e,n,i=0,r=t.length){let s=new iie(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class iie{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:c,to:u}=e;if(c>=i||u<=n)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let h=r,d=rie(e)||Su.empty,m=tie(s,d.tags);if(m&&(h&&(h+=" "),h+=m,d.mode==1&&(r+=(r?" ":"")+m)),this.startSpan(Math.max(n,c),h),d.opaque)return;let g=e.tree&&e.tree.prop(Fe.mounted);if(g&&g.overlay){let y=e.node.enter(g.overlay[0].from+c,1),x=this.highlighters.filter(S=>!S.scope||S.scope(g.tree.type)),w=e.firstChild();for(let S=0,C=c;;S++){let A=S<g.overlay.length?g.overlay[S]:null,O=A?A.from+c:u,E=Math.max(n,C),T=Math.min(i,O);if(E<T&&w)for(;e.from<T&&(this.highlightRange(e,E,T,r,s),this.startSpan(Math.min(T,e.to),h),!(e.to>=O||!e.nextSibling())););if(!A||O>i)break;C=A.to+c,C>n&&(this.highlightRange(y.cursor(),Math.max(n,A.from+c),Math.min(i,C),"",x),this.startSpan(Math.min(i,C),h))}w&&e.parent()}else if(e.firstChild()){g&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function rie(t){let e=t.type.prop(cq);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const xe=Ur.define,Yh=xe(),Ls=xe(),M5=xe(Ls),R5=xe(Ls),zs=xe(),Qh=xe(zs),yw=xe(zs),Ji=xe(),ka=xe(Ji),Ki=xe(),Zi=xe(),QS=xe(),Dc=xe(QS),Xh=xe(),le={comment:Yh,lineComment:xe(Yh),blockComment:xe(Yh),docComment:xe(Yh),name:Ls,variableName:xe(Ls),typeName:M5,tagName:xe(M5),propertyName:R5,attributeName:xe(R5),className:xe(Ls),labelName:xe(Ls),namespace:xe(Ls),macroName:xe(Ls),literal:zs,string:Qh,docString:xe(Qh),character:xe(Qh),attributeValue:xe(Qh),number:yw,integer:xe(yw),float:xe(yw),bool:xe(zs),regexp:xe(zs),escape:xe(zs),color:xe(zs),url:xe(zs),keyword:Ki,self:xe(Ki),null:xe(Ki),atom:xe(Ki),unit:xe(Ki),modifier:xe(Ki),operatorKeyword:xe(Ki),controlKeyword:xe(Ki),definitionKeyword:xe(Ki),moduleKeyword:xe(Ki),operator:Zi,derefOperator:xe(Zi),arithmeticOperator:xe(Zi),logicOperator:xe(Zi),bitwiseOperator:xe(Zi),compareOperator:xe(Zi),updateOperator:xe(Zi),definitionOperator:xe(Zi),typeOperator:xe(Zi),controlOperator:xe(Zi),punctuation:QS,separator:xe(QS),bracket:Dc,angleBracket:xe(Dc),squareBracket:xe(Dc),paren:xe(Dc),brace:xe(Dc),content:Ji,heading:ka,heading1:xe(ka),heading2:xe(ka),heading3:xe(ka),heading4:xe(ka),heading5:xe(ka),heading6:xe(ka),contentSeparator:xe(Ji),list:xe(Ji),quote:xe(Ji),emphasis:xe(Ji),strong:xe(Ji),link:xe(Ji),monospace:xe(Ji),strikethrough:xe(Ji),inserted:xe(),deleted:xe(),changed:xe(),invalid:xe(),meta:Xh,documentMeta:xe(Xh),annotation:xe(Xh),processingInstruction:xe(Xh),definition:Ur.defineModifier("definition"),constant:Ur.defineModifier("constant"),function:Ur.defineModifier("function"),standard:Ur.defineModifier("standard"),local:Ur.defineModifier("local"),special:Ur.defineModifier("special")};for(let t in le){let e=le[t];e instanceof Ur&&(e.name=t)}uq([{tag:le.link,class:"tok-link"},{tag:le.heading,class:"tok-heading"},{tag:le.emphasis,class:"tok-emphasis"},{tag:le.strong,class:"tok-strong"},{tag:le.keyword,class:"tok-keyword"},{tag:le.atom,class:"tok-atom"},{tag:le.bool,class:"tok-bool"},{tag:le.url,class:"tok-url"},{tag:le.labelName,class:"tok-labelName"},{tag:le.inserted,class:"tok-inserted"},{tag:le.deleted,class:"tok-deleted"},{tag:le.literal,class:"tok-literal"},{tag:le.string,class:"tok-string"},{tag:le.number,class:"tok-number"},{tag:[le.regexp,le.escape,le.special(le.string)],class:"tok-string2"},{tag:le.variableName,class:"tok-variableName"},{tag:le.local(le.variableName),class:"tok-variableName tok-local"},{tag:le.definition(le.variableName),class:"tok-variableName tok-definition"},{tag:le.special(le.variableName),class:"tok-variableName2"},{tag:le.definition(le.propertyName),class:"tok-propertyName tok-definition"},{tag:le.typeName,class:"tok-typeName"},{tag:le.namespace,class:"tok-namespace"},{tag:le.className,class:"tok-className"},{tag:le.macroName,class:"tok-macroName"},{tag:le.propertyName,class:"tok-propertyName"},{tag:le.operator,class:"tok-operator"},{tag:le.comment,class:"tok-comment"},{tag:le.meta,class:"tok-meta"},{tag:le.invalid,class:"tok-invalid"},{tag:le.punctuation,class:"tok-punctuation"}]);var vw;const Wo=new Fe;function sie(t){return ke.define({combine:t?e=>e.concat(t):void 0})}const aie=new Fe;class Bi{constructor(e,n,i=[],r=""){this.data=e,this.name=r,Je.prototype.hasOwnProperty("tree")||Object.defineProperty(Je.prototype,"tree",{get(){return Cn(this)}}),this.parser=n,this.extension=[Ks.of(this),Je.languageData.of((s,o,c)=>{let u=N5(s,o,c),h=u.type.prop(Wo);if(!h)return[];let d=s.facet(h),m=u.type.prop(aie);if(m){let g=u.resolve(o-u.from,c);for(let y of m)if(y.test(g,s)){let x=s.facet(y.facet);return y.type=="replace"?x:x.concat(d)}}return d})].concat(i)}isActiveAt(e,n,i=-1){return N5(e,n,i).type.prop(Wo)==this.data}findRegions(e){let n=e.facet(Ks);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Wo)==this.data){i.push({from:o,to:o+s.length});return}let c=s.prop(Fe.mounted);if(c){if(c.tree.prop(Wo)==this.data){if(c.overlay)for(let u of c.overlay)i.push({from:u.from+o,to:u.to+o});else i.push({from:o,to:o+s.length});return}else if(c.overlay){let u=i.length;if(r(c.tree,c.overlay[0].from+o),i.length>u)return}}for(let u=0;u<s.children.length;u++){let h=s.children[u];h instanceof It&&r(h,s.positions[u]+o)}};return r(Cn(e),0),i}get allowsNesting(){return!0}}Bi.setState=je.define();function N5(t,e,n){let i=t.facet(Ks),r=Cn(t).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,n,Nt.ExcludeBuffers|Nt.EnterBracketed))s.type.isTop&&(r=s);return r}class Gd extends Bi{constructor(e,n,i){super(e,n,[],i),this.parser=n}static define(e){let n=sie(e.languageData);return new Gd(n,e.parser.configure({props:[Wo.add(i=>i.isTop?n:void 0)]}),e.name)}configure(e,n){return new Gd(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Cn(t){let e=t.field(Bi.state,!1);return e?e.tree:It.empty}class oie{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,n){let i=this.cursorPos-this.string.length;return e<i||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let Lc=null;class Yd{constructor(e,n,i=[],r,s,o,c,u){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=c,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new Yd(e,n,[],It.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oie(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=It.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ja.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(ja.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Lc;Lc=this;try{return e()}finally{Lc=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=D5(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:c}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((h,d,m,g)=>u.push({fromA:h,toA:d,fromB:m,toB:g})),i=ja.applyChanges(i,u),r=It.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){c=[];for(let h of this.skipped){let d=e.mapPos(h.from,1),m=e.mapPos(h.to,-1);d<m&&c.push({from:d,to:m})}}}return new Yd(this.parser,n,i,r,s,o,c,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=D5(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends oq{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let u=Lc;if(u){for(let h of r)u.tempSkipped.push(h);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new It(Xn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Lc}}function D5(t,e,n){return ja.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class vl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new vl(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=Yd.create(e.facet(Ks).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new vl(i)}}Bi.state=_n.define({create:vl.init,update(t,e){for(let n of e.effects)if(n.is(Bi.setState))return n.value;return e.startState.facet(Ks)!=e.state.facet(Ks)?vl.init(e.state):t.apply(e)}});let fq=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(fq=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const bw=typeof navigator<"u"&&(!((vw=navigator.scheduling)===null||vw===void 0)&&vw.isInputPending)?()=>navigator.scheduling.isInputPending():null,lie=zt.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 n=this.view.state.field(Bi.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Bi.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=fq(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(Bi.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!bw?Math.max(25,e.timeRemaining()-5):1e9),c=s.context.treeLen<r&&i.doc.length>r+1e3,u=s.context.work(()=>bw&&bw()||Date.now()>o,r+(c?0:1e5));this.chunkBudget-=Date.now()-n,(u||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Bi.setState.of(new vl(s.context))})),this.chunkBudget>0&&!(u&&!c)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fn(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ks=ke.define({combine(t){return t.length?t[0]:null},enables:t=>[Bi.state,lie,Se.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class cie{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const uie=ke.define(),Vp=ke.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Qd(t){let e=t.facet(Vp);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Cu(t,e){let n="",i=t.tabSize,r=t.facet(Vp)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s<e;s++)n+=r;return n}function _C(t,e){t instanceof Je&&(t=new Fp(t));for(let i of t.state.facet(uie)){let r=i(t,e);if(r!==void 0)return r}let n=Cn(t.state);return n.length>=e?fie(t,n,e):null}class Fp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Qd(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,n);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return Ol(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const hq=new Fe;function fie(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return dq(i,t,n)}function dq(t,e,n){for(let i=t;i;i=i.next){let r=die(i.node);if(r)return r(OC.create(e,n,i))}return 0}function hie(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function die(t){let e=t.type.prop(hq);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(Fe.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>pq(o,!0,1,void 0,s&&!hie(o)?r.from:void 0)}return t.parent==null?pie:null}function pie(){return 0}class OC extends Fp{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new OC(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(mie(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return dq(this.context.next,this.base,this.pos)}}function mie(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function gie(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let c=n.to;;){let u=e.childAfter(c);if(!u||u==i)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let h=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+h}}c=u.to}}function L5({closing:t,align:e=!0,units:n=1}){return i=>pq(i,e,n,t)}function pq(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,c=i&&s.slice(o,o+i.length)==i||r==t.pos+o,u=e?gie(t):null;return u?c?t.column(u.from):t.column(u.to):t.baseIndent+(c?0:t.unit*n)}const yie=200;function vie(){return Je.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+yie)return t;let s=n.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return t;let{state:o}=t,c=-1,u=[];for(let{head:h}of o.selection.ranges){let d=o.doc.lineAt(h);if(d.from==c)continue;c=d.from;let m=_C(o,d.from);if(m==null)continue;let g=/^\s*/.exec(d.text)[0],y=Cu(o,m);g!=y&&u.push({from:d.from,to:d.from+g.length,insert:y})}return u.length?[t,{changes:u,sequential:!0}]:t})}const bie=ke.define(),mq=new Fe;function xie(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function wie(t,e,n){let i=Cn(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let c=o.node;if(c.to<=n||c.from>n)continue;if(s&&c.from<e)break;let u=c.type.prop(mq);if(u&&(c.to<i.length-50||i.length==t.doc.length||!Sie(c))){let h=u(c,t);h&&h.from<=n&&h.from>=e&&h.to>n&&(s=h)}}return s}function Sie(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Xd(t,e,n){for(let i of t.facet(bie)){let r=i(t,e,n);if(r)return r}return wie(t,e,n)}function gq(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}const $p=je.define({map:gq}),Fu=je.define({map:gq});function yq(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(i=>i.from<=n&&i.to>=n)||e.push(t.lineBlockAt(n));return e}const $a=_n.define({create(){return Le.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,i)=>t=z5(t,n,i)),t=t.map(e.changes);for(let n of e.effects)if(n.is($p)&&!Cie(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(xq),r=i?Le.replace({widget:new Mie(i(e.state,n.value))}):B5;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(Fu)&&(t=t.update({filter:(i,r)=>n.value.from!=i||n.value.to!=r,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=z5(t,e.selection.main.head)),t},provide:t=>Se.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(i,r)=>{n.push(i,r)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(B5.range(i,r))}return Le.set(e,!0)}});function z5(t,e,n=e){let i=!1;return t.between(e,n,(r,s)=>{r<n&&s>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(r,s)=>r>=n||s<=e}):t}function Wd(t,e,n){var i;let r=null;return(i=t.field($a,!1))===null||i===void 0||i.between(e,n,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Cie(t,e,n){let i=!1;return t.between(e,e,(r,s)=>{r==e&&s==n&&(i=!0)}),i}function vq(t,e){return t.field($a,!1)?e:e.concat(je.appendConfig.of(wq()))}const kie=t=>{for(let e of yq(t)){let n=Xd(t.state,e.from,e.to);if(n)return t.dispatch({effects:vq(t.state,[$p.of(n),bq(t,n)])}),!0}return!1},Aie=t=>{if(!t.state.field($a,!1))return!1;let e=[];for(let n of yq(t)){let i=Wd(t.state,n.from,n.to);i&&e.push(Fu.of(i),bq(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function bq(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return Se.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}const _ie=t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=Xd(e,r.from,r.to);s&&n.push($p.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:vq(t.state,n)}),!!n.length},Oie=t=>{let e=t.state.field($a,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(i,r)=>{n.push(Fu.of({from:i,to:r}))}),t.dispatch({effects:n}),!0},Eie=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:kie},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Aie},{key:"Ctrl-Alt-[",run:_ie},{key:"Ctrl-Alt-]",run:Oie}],Tie={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},xq=ke.define({combine(t){return pr(t,Tie)}});function wq(t){return[$a,Die]}function Sq(t,e){let{state:n}=t,i=n.facet(xq),r=o=>{let c=t.lineBlockAt(t.posAtDOM(o.target)),u=Wd(t.state,c.from,c.to);u&&t.dispatch({effects:Fu.of(u)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const B5=Le.replace({widget:new class extends mr{toDOM(t){return Sq(t,null)}}});class Mie extends mr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Sq(e,this.value)}}const Rie={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class xw extends Jr{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function Nie(t={}){let e={...Rie,...t},n=new xw(e,!0),i=new xw(e,!1),r=zt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Ks)!=o.state.facet(Ks)||o.startState.field($a,!1)!=o.state.field($a,!1)||Cn(o.startState)!=Cn(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let c=new Kr;for(let u of o.viewportLineBlocks){let h=Wd(o.state,u.from,u.to)?i:Xd(o.state,u.from,u.to)?n:null;h&&c.add(u.from,u.from,h)}return c.finish()}}),{domEventHandlers:s}=e;return[r,Dne({class:"cm-foldGutter",markers(o){var c;return((c=o.plugin(r))===null||c===void 0?void 0:c.markers)||Ye.empty},initialSpacer(){return new xw(e,!1)},domEventHandlers:{...s,click:(o,c,u)=>{if(s.click&&s.click(o,c,u))return!0;let h=Wd(o.state,c.from,c.to);if(h)return o.dispatch({effects:Fu.of(h)}),!0;let d=Xd(o.state,c.from,c.to);return d?(o.dispatch({effects:$p.of(d)}),!0):!1}}}),wq()]}const Die=Se.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"}});class $u{constructor(e,n){this.specs=e;let i;function r(c){let u=Ys.newName();return(i||(i=Object.create(null)))["."+u]=c,u}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,o=n.scope;this.scope=o instanceof Bi?c=>c.prop(Wo)==o.data:o?c=>c==o:void 0,this.style=uq(e.map(c=>({tag:c.tag,class:c.class||r(Object.assign({},c,{tag:null}))})),{all:s}).style,this.module=i?new Ys(i):null,this.themeType=n.themeType}static define(e,n){return new $u(e,n||{})}}const XS=ke.define(),Cq=ke.define({combine(t){return t.length?[t[0]]:null}});function ww(t){let e=t.facet(XS);return e.length?e:t.facet(Cq)}function kq(t,e){let n=[zie],i;return t instanceof $u&&(t.module&&n.push(Se.styleModule.of(t.module)),i=t.themeType),e?.fallback?n.push(Cq.of(t)):i?n.push(XS.computeN([Se.darkTheme],r=>r.facet(Se.darkTheme)==(i=="dark")?[t]:[])):n.push(XS.of(t)),n}class Lie{constructor(e){this.markCache=Object.create(null),this.tree=Cn(e.state),this.decorations=this.buildDeco(e,ww(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Cn(e.state),i=ww(e.state),r=i!=ww(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!r&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Le.none;let i=new Kr;for(let{from:r,to:s}of e.visibleRanges)nie(this.tree,n,(o,c,u)=>{i.add(o,c,this.markCache[u]||(this.markCache[u]=Le.mark({class:u})))},r,s);return i.finish()}}const zie=Za.high(zt.fromClass(Lie,{decorations:t=>t.decorations})),Bie=$u.define([{tag:le.meta,color:"#404740"},{tag:le.link,textDecoration:"underline"},{tag:le.heading,textDecoration:"underline",fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strong,fontWeight:"bold"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.keyword,color:"#708"},{tag:[le.atom,le.bool,le.url,le.contentSeparator,le.labelName],color:"#219"},{tag:[le.literal,le.inserted],color:"#164"},{tag:[le.string,le.deleted],color:"#a11"},{tag:[le.regexp,le.escape,le.special(le.string)],color:"#e40"},{tag:le.definition(le.variableName),color:"#00f"},{tag:le.local(le.variableName),color:"#30a"},{tag:[le.typeName,le.namespace],color:"#085"},{tag:le.className,color:"#167"},{tag:[le.special(le.variableName),le.macroName],color:"#256"},{tag:le.definition(le.propertyName),color:"#00c"},{tag:le.comment,color:"#940"},{tag:le.invalid,color:"#f00"}]),qie=Se.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Aq=1e4,_q="()[]{}",Oq=ke.define({combine(t){return pr(t,{afterCursor:!0,brackets:_q,maxScanDistance:Aq,renderMatch:Pie})}}),jie=Le.mark({class:"cm-matchingBracket"}),Iie=Le.mark({class:"cm-nonmatchingBracket"});function Pie(t){let e=[],n=t.matched?jie:Iie;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}function q5(t){let e=[],n=t.facet(Oq);for(let i of t.selection.ranges){if(!i.empty)continue;let r=ar(t,i.head,-1,n)||i.head>0&&ar(t,i.head-1,1,n)||n.afterCursor&&(ar(t,i.head,1,n)||i.head<t.doc.length&&ar(t,i.head+1,-1,n));r&&(e=e.concat(n.renderMatch(r,t)))}return Le.set(e,!0)}const Hie=zt.fromClass(class{constructor(t){this.paused=!1,this.decorations=q5(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=q5(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Uie=[Hie,qie];function Vie(t={}){return[Oq.of(t),Uie]}const Fie=new Fe;function WS(t,e,n){let i=t.prop(e<0?Fe.openedBy:Fe.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function KS(t){let e=t.type.prop(Fie);return e?e(t.node):t}function ar(t,e,n,i={}){let r=i.maxScanDistance||Aq,s=i.brackets||_q,o=Cn(t),c=o.resolveInner(e,n);for(let u=c;u;u=u.parent){let h=WS(u.type,n,s);if(h&&u.from<u.to){let d=KS(u);if(d&&(n>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return $ie(t,e,n,u,d,h,s)}}return Gie(t,e,n,o,c.type,r,s)}function $ie(t,e,n,i,r,s,o){let c=i.parent,u={from:r.from,to:r.to},h=0,d=c?.cursor();if(d&&(n<0?d.childBefore(i.from):d.childAfter(i.to)))do if(n<0?d.to<=i.from:d.from>=i.to){if(h==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let m=KS(d);return{start:u,end:m?{from:m.from,to:m.to}:void 0,matched:!0}}else if(WS(d.type,n,o))h++;else if(WS(d.type,-n,o)){if(h==0){let m=KS(d);return{start:u,end:m&&m.from<m.to?{from:m.from,to:m.to}:void 0,matched:!1}}h--}}while(n<0?d.prevSibling():d.nextSibling());return{start:u,matched:!1}}function Gie(t,e,n,i,r,s,o){let c=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),u=o.indexOf(c);if(u<0||u%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},d=t.doc.iterRange(e,n>0?t.doc.length:0),m=0;for(let g=0;!d.next().done&&g<=s;){let y=d.value;n<0&&(g+=y.length);let x=e+g*n;for(let w=n>0?0:y.length-1,S=n>0?y.length:-1;w!=S;w+=n){let C=o.indexOf(y[w]);if(!(C<0||i.resolveInner(x+w,1).type!=r))if(C%2==0==n>0)m++;else{if(m==1)return{start:h,end:{from:x+w,to:x+w+1},matched:C>>1==u>>1};m--}}n>0&&(g+=y.length)}return d.done?{start:h,matched:!1}:null}const Yie=Object.create(null),j5=[Xn.none],I5=[],P5=Object.create(null),Qie=Object.create(null);for(let[t,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"]])Qie[t]=Xie(Yie,e);function Sw(t,e){I5.indexOf(t)>-1||(I5.push(t),console.warn(e))}function Xie(t,e){let n=[];for(let c of e.split(" ")){let u=[];for(let h of c.split(".")){let d=t[h]||le[h];d?typeof d=="function"?u.length?u=u.map(d):Sw(h,`Modifier ${h} used at start of tag`):u.length?Sw(h,`Tag ${h} used as modifier`):u=Array.isArray(d)?d:[d]:Sw(h,`Unknown highlighting tag ${h}`)}for(let h of u)n.push(h)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(c=>c.id),s=P5[r];if(s)return s.id;let o=P5[r]=Xn.define({id:j5.length,name:i,props:[lq({[i]:n})]});return j5.push(o),o.id}yt.RTL,yt.LTR;const Wie=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=TC(t.state,n.from);return i.line?Kie(t):i.block?Jie(t):!1};function EC(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const Kie=EC(nre,0),Zie=EC(Eq,0),Jie=EC((t,e)=>Eq(t,e,tre(e)),0);function TC(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const zc=50;function ere(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-zc,i),o=t.sliceDoc(r,r+zc),c=/\s*$/.exec(s)[0].length,u=/^\s*/.exec(o)[0].length,h=s.length-c;if(s.slice(h-e.length,h)==e&&o.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+u,margin:u&&1}};let d,m;r-i<=2*zc?d=m=t.sliceDoc(i,r):(d=t.sliceDoc(i,i+zc),m=t.sliceDoc(r-zc,r));let g=/^\s*/.exec(d)[0].length,y=/\s*$/.exec(m)[0].length,x=m.length-y-n.length;return d.slice(g,g+e.length)==e&&m.slice(x,x+n.length)==n?{open:{pos:i+g+e.length,margin:/\s/.test(d.charAt(g+e.length))?1:0},close:{pos:r-y-n.length,margin:/\s/.test(m.charAt(x-1))?1:0}}:null}function tre(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function Eq(t,e,n=e.selection.ranges){let i=n.map(s=>TC(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>ere(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,c;o<r.length;o++)if(c=r[o]){let u=i[o],{open:h,close:d}=c;s.push({from:h.pos-u.open.length,to:h.pos+h.margin},{from:d.pos-d.margin,to:d.pos+u.close.length})}return{changes:s}}return null}function nre(t,e,n=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of n){let c=i.length,u=1e9,h;for(let d=s;d<=o;){let m=e.doc.lineAt(d);if(h==null&&(h=TC(e,m.from).line,!h))continue e;if(m.from>r&&(s==o||o>m.from)){r=m.from;let g=/^\s*/.exec(m.text)[0].length,y=g==m.length,x=m.text.slice(g,g+h.length)==h?g:-1;g<m.text.length&&g<u&&(u=g),i.push({line:m,comment:x,token:h,indent:g,empty:y,single:!1})}d=m.to+1}if(u<1e9)for(let d=c;d<i.length;d++)i[d].indent<i[d].line.text.length&&(i[d].indent=u);i.length==c+1&&(i[c].single=!0)}if(t!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:c,token:u,indent:h,empty:d,single:m}of i)(m||!d)&&s.push({from:c.from+h,insert:u+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:c,token:u}of i)if(c>=0){let h=o.from+c,d=h+u.length;o.text[d-o.from]==" "&&d++,s.push({from:h,to:d})}return{changes:s}}return null}const ZS=dr.define(),ire=dr.define(),rre=ke.define(),Tq=ke.define({combine(t){return pr(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),Mq=_n.define({create(){return or.empty},update(t,e){let n=e.state.facet(Tq),i=e.annotation(ZS);if(i){let u=$n.fromTransaction(e,i.selection),h=i.side,d=h==0?t.undone:t.done;return u?d=Zd(d,d.length,n.minDepth,u):d=Nq(d,e.startState.selection),new or(h==0?i.rest:d,h==0?d:i.rest)}let r=e.annotation(ire);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Qt.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=$n.fromTransaction(e),o=e.annotation(Qt.time),c=e.annotation(Qt.userEvent);return s?t=t.addChanges(s,o,c,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,c,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new or(t.done.map($n.fromJSON),t.undone.map($n.fromJSON))}});function sre(t={}){return[Mq,Tq.of(t),Se.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?MC:e.inputType=="historyRedo"?Kd:null;return i?(e.preventDefault(),i(n)):!1}})]}function Gp(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(Mq,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const MC=Gp(0,!1),Kd=Gp(1,!1),are=Gp(0,!0),ore=Gp(1,!0);class $n{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new $n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new $n(e.changes&&en.fromJSON(e.changes),[],e.mapped&&ur.fromJSON(e.mapped),e.startSelection&&de.fromJSON(e.startSelection),e.selectionsAfter.map(de.fromJSON))}static fromTransaction(e,n){let i=ki;for(let r of e.startState.facet(rre)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new $n(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,ki)}static selection(e){return new $n(void 0,ki,void 0,void 0,e)}}function Zd(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function lre(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,c)=>{for(let u=0;u<n.length;){let h=n[u++],d=n[u++];c>=h&&o<=d&&(i=!0)}}),i}function cre(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function Rq(t,e){return t.length?e.length?t.concat(e):t:e}const ki=[],ure=200;function Nq(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ure));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),Zd(t,t.length-1,1e9,n.setSelAfter(i)))}else return[$n.selection([e])]}function fre(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Cw(t,e){if(!t.length)return t;let n=t.length,i=ki;for(;n;){let r=hre(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[$n.selection(i)]:ki}function hre(t,e,n){let i=Rq(t.selectionsAfter.length?t.selectionsAfter.map(c=>c.map(e)):ki,n);if(!t.changes)return $n.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new $n(r,je.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const dre=/^(input\.type|delete)($|\.)/;class or{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new or(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,c=o[o.length-1];return c&&c.changes&&!c.changes.empty&&e.changes&&(!i||dre.test(i))&&(!c.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,lre(c.changes,e.changes))||i=="input.type.compose")?o=Zd(o,o.length-1,r.minDepth,new $n(e.changes.compose(c.changes),Rq(je.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,ki)):o=Zd(o,o.length,r.minDepth,e),new or(o,ki,n,i)}addSelection(e,n,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:ki;return s.length>0&&n-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&cre(s[s.length-1],e)?this:new or(Nq(this.done,e),this.undone,n,i)}addMapping(e){return new or(Cw(this.done,e),Cw(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(i&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:ZS.of({side:e,rest:fre(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let c=r.length==1?ki:r.slice(0,r.length-1);return s.mapped&&(c=Cw(c,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:ZS.of({side:e,rest:c,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}or.empty=new or(ki,ki);const pre=[{key:"Mod-z",run:MC,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Kd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Kd,preventDefault:!0},{key:"Mod-u",run:are,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ore,preventDefault:!0}];function El(t,e){return de.create(t.ranges.map(e),t.mainIndex)}function Ui(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Vi({state:t,dispatch:e},n){let i=El(t.selection,n);return i.eq(t.selection,!0)?!1:(e(Ui(t,i)),!0)}function Yp(t,e){return de.cursor(e?t.to:t.from)}function Dq(t,e){return Vi(t,n=>n.empty?t.moveByChar(n,e):Yp(n,e))}function On(t){return t.textDirectionAt(t.state.selection.main.head)==yt.LTR}const Lq=t=>Dq(t,!On(t)),zq=t=>Dq(t,On(t));function Bq(t,e){return Vi(t,n=>n.empty?t.moveByGroup(n,e):Yp(n,e))}const mre=t=>Bq(t,!On(t)),gre=t=>Bq(t,On(t));function yre(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Qp(t,e,n){let i=Cn(t).resolveInner(e.head),r=n?Fe.closedBy:Fe.openedBy;for(let u=e.head;;){let h=n?i.childAfter(u):i.childBefore(u);if(!h)break;yre(t,h,r)?i=h:u=n?h.to:h.from}let s=i.type.prop(r),o,c;return s&&(o=n?ar(t,i.from,1):ar(t,i.to,-1))&&o.matched?c=n?o.end.to:o.end.from:c=n?i.to:i.from,de.cursor(c,n?-1:1)}const vre=t=>Vi(t,e=>Qp(t.state,e,!On(t))),bre=t=>Vi(t,e=>Qp(t.state,e,On(t)));function qq(t,e){return Vi(t,n=>{if(!n.empty)return Yp(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const jq=t=>qq(t,!1),Iq=t=>qq(t,!0);function Pq(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let s of t.state.facet(Se.scrollMargins)){let o=s(t);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Hq(t,e){let n=Pq(t),{state:i}=t,r=El(i.selection,o=>o.empty?t.moveVertically(o,e,n.height):Yp(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),c=t.scrollDOM.getBoundingClientRect(),u=c.top+n.marginTop,h=c.bottom-n.marginBottom;o&&o.top>u&&o.bottom<h&&(s=Se.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-u}))}return t.dispatch(Ui(i,r),{effects:s}),!0}const H5=t=>Hq(t,!1),JS=t=>Hq(t,!0);function ta(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=de.cursor(i.from+s))}return r}const xre=t=>Vi(t,e=>ta(t,e,!0)),wre=t=>Vi(t,e=>ta(t,e,!1)),Sre=t=>Vi(t,e=>ta(t,e,!On(t))),Cre=t=>Vi(t,e=>ta(t,e,On(t))),kre=t=>Vi(t,e=>de.cursor(t.lineBlockAt(e.head).from,1)),Are=t=>Vi(t,e=>de.cursor(t.lineBlockAt(e.head).to,-1));function _re(t,e,n){let i=!1,r=El(t.selection,s=>{let o=ar(t,s.head,-1)||ar(t,s.head,1)||s.head>0&&ar(t,s.head-1,1)||s.head<t.doc.length&&ar(t,s.head+1,-1);if(!o||!o.end)return s;i=!0;let c=o.start.from==s.head?o.end.to:o.end.from;return de.cursor(c)});return i?(e(Ui(t,r)),!0):!1}const Ore=({state:t,dispatch:e})=>_re(t,e);function Ti(t,e){let n=El(t.state.selection,i=>{let r=e(i);return de.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(Ui(t.state,n)),!0)}function Uq(t,e){return Ti(t,n=>t.moveByChar(n,e))}const Vq=t=>Uq(t,!On(t)),Fq=t=>Uq(t,On(t));function $q(t,e){return Ti(t,n=>t.moveByGroup(n,e))}const Ere=t=>$q(t,!On(t)),Tre=t=>$q(t,On(t)),Mre=t=>Ti(t,e=>Qp(t.state,e,!On(t))),Rre=t=>Ti(t,e=>Qp(t.state,e,On(t)));function Gq(t,e){return Ti(t,n=>t.moveVertically(n,e))}const Yq=t=>Gq(t,!1),Qq=t=>Gq(t,!0);function Xq(t,e){return Ti(t,n=>t.moveVertically(n,e,Pq(t).height))}const U5=t=>Xq(t,!1),V5=t=>Xq(t,!0),Nre=t=>Ti(t,e=>ta(t,e,!0)),Dre=t=>Ti(t,e=>ta(t,e,!1)),Lre=t=>Ti(t,e=>ta(t,e,!On(t))),zre=t=>Ti(t,e=>ta(t,e,On(t))),Bre=t=>Ti(t,e=>de.cursor(t.lineBlockAt(e.head).from)),qre=t=>Ti(t,e=>de.cursor(t.lineBlockAt(e.head).to)),F5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:0})),!0),$5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.doc.length})),!0),G5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.selection.main.anchor,head:0})),!0),Y5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),jre=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),Ire=({state:t,dispatch:e})=>{let n=Xp(t).map(({from:i,to:r})=>de.range(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:de.create(n),userEvent:"select"})),!0},Pre=({state:t,dispatch:e})=>{let n=El(t.selection,i=>{let r=Cn(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:c}=o;if((c.from<i.from&&c.to>=i.to||c.to>i.to&&c.from<=i.from)&&o.next)return de.range(c.to,c.from)}return i});return n.eq(t.selection)?!1:(e(Ui(t,n)),!0)};function Wq(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let c=s;;){let u=t.moveVertically(c,e);if(u.head<o.from||u.head>o.to){r.some(h=>h.head==u.head)||r.push(u);break}else{if(u.head==c.head)break;c=u}}}return r.length==i.ranges.length?!1:(t.dispatch(Ui(n,de.create(r,r.length-1))),!0)}const Hre=t=>Wq(t,!1),Ure=t=>Wq(t,!0),Vre=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=de.create([n.main]):n.main.empty||(i=de.create([de.cursor(n.main.head)])),i?(e(Ui(t,i)),!0):!1};function Gu(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:c}=s;if(o==c){let u=e(s);u<o?(n="delete.backward",u=Wh(t,u,!1)):u>o&&(n="delete.forward",u=Wh(t,u,!0)),o=Math.min(o,u),c=Math.max(c,u)}else o=Wh(t,o,!1),c=Wh(t,c,!0);return o==c?{range:s}:{changes:{from:o,to:c},range:de.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?Se.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Wh(t,e,n){if(t instanceof Se)for(let i of t.state.facet(Se.atomicRanges).map(r=>r(t)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=n?s:r)});return e}const Kq=(t,e,n)=>Gu(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),c,u;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(c=o.text.slice(0,r-o.from))){if(c[c.length-1]==" ")return r-1;let h=Ol(c,s.tabSize),d=h%Qd(s)||Qd(s);for(let m=0;m<d&&c[c.length-1-m]==" ";m++)r--;u=r}else u=sn(o.text,r-o.from,e,e)+o.from,u==r&&o.number!=(e?s.doc.lines:1)?u+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(u-o.from,r-o.from))&&(u=sn(o.text,u-o.from,!1,!1)+o.from);return u}),e2=t=>Kq(t,!1,!0),Zq=t=>Kq(t,!0,!1),Jq=(t,e)=>Gu(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let c=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let u=sn(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,u)-s.from,Math.max(i,u)-s.from),d=o(h);if(c!=null&&d!=c)break;(h!=" "||i!=n.head)&&(c=d),i=u}return i}),ej=t=>Jq(t,!1),Fre=t=>Jq(t,!0),$re=t=>Gu(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Gre=t=>Gu(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),Yre=t=>Gu(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Qre=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:tt.of(["",""])},range:de.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Xre=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:sn(s.text,r-s.from,!1)+s.from,c=r==s.to?r+1:sn(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:c,insert:t.doc.slice(r,c).append(t.doc.slice(o,r))},range:de.cursor(c)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xp(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function tj(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of Xp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),c=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let u of s.ranges)r.push(de.range(Math.min(t.doc.length,u.anchor+c),Math.min(t.doc.length,u.head+c)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let u of s.ranges)r.push(de.range(u.anchor-c,u.head-c))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:de.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Wre=({state:t,dispatch:e})=>tj(t,e,!1),Kre=({state:t,dispatch:e})=>tj(t,e,!0);function nj(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of Xp(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Zre=({state:t,dispatch:e})=>nj(t,e,!1),Jre=({state:t,dispatch:e})=>nj(t,e,!0),ese=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Xp(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=El(e.selection,r=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),c=t.coordsAtPos(r.head,r.assoc||1);c&&(s=o.bottom+t.documentTop-c.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function tse(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Cn(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(Fe.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const Q5=ij(!1),nse=ij(!0);function ij(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,c=e.doc.lineAt(s),u=!t&&s==o&&tse(e,s);t&&(s=o=(o<=c.to?c:e.doc.lineAt(o)).to);let h=new Fp(e,{simulateBreak:s,simulateDoubleBreak:!!u}),d=_C(h,s);for(d==null&&(d=Ol(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<c.to&&/\s/.test(c.text[o-c.from]);)o++;u?{from:s,to:o}=u:s>c.from&&s<c.from+100&&!/\S/.test(c.text.slice(0,s))&&(s=c.from);let m=["",Cu(e,d)];return u&&m.push(Cu(e,h.lineIndent(c.from,-1))),{changes:{from:s,to:o,insert:tt.of(m)},range:de.cursor(s+1+m[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function RC(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let c=t.doc.lineAt(o);c.number>n&&(i.empty||i.to>c.from)&&(e(c,r,i),n=c.number),o=c.to+1}let s=t.changes(r);return{changes:r,range:de.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const ise=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new Fp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=RC(t,(s,o,c)=>{let u=_C(i,s.from);if(u==null)return;/\S/.test(s.text)||(u=0);let h=/^\s*/.exec(s.text)[0],d=Cu(t,u);(h!=d||c.from<s.from+h.length)&&(n[s.from]=u,o.push({from:s.from,to:s.from+h.length,insert:d}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},rj=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(RC(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Vp)})}),{userEvent:"input.indent"})),!0),sj=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(RC(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=Ol(r,t.tabSize),o=0,c=Cu(t,Math.max(0,s-Qd(t)));for(;o<r.length&&o<c.length&&r.charCodeAt(o)==c.charCodeAt(o);)o++;i.push({from:n.from+o,to:n.from+r.length,insert:c.slice(o)})}),{userEvent:"delete.dedent"})),!0),rse=t=>(t.setTabFocusMode(),!0),sse=[{key:"Ctrl-b",run:Lq,shift:Vq,preventDefault:!0},{key:"Ctrl-f",run:zq,shift:Fq},{key:"Ctrl-p",run:jq,shift:Yq},{key:"Ctrl-n",run:Iq,shift:Qq},{key:"Ctrl-a",run:kre,shift:Bre},{key:"Ctrl-e",run:Are,shift:qre},{key:"Ctrl-d",run:Zq},{key:"Ctrl-h",run:e2},{key:"Ctrl-k",run:$re},{key:"Ctrl-Alt-h",run:ej},{key:"Ctrl-o",run:Qre},{key:"Ctrl-t",run:Xre},{key:"Ctrl-v",run:JS}],ase=[{key:"ArrowLeft",run:Lq,shift:Vq,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:mre,shift:Ere,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Sre,shift:Lre,preventDefault:!0},{key:"ArrowRight",run:zq,shift:Fq,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:gre,shift:Tre,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Cre,shift:zre,preventDefault:!0},{key:"ArrowUp",run:jq,shift:Yq,preventDefault:!0},{mac:"Cmd-ArrowUp",run:F5,shift:G5},{mac:"Ctrl-ArrowUp",run:H5,shift:U5},{key:"ArrowDown",run:Iq,shift:Qq,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$5,shift:Y5},{mac:"Ctrl-ArrowDown",run:JS,shift:V5},{key:"PageUp",run:H5,shift:U5},{key:"PageDown",run:JS,shift:V5},{key:"Home",run:wre,shift:Dre,preventDefault:!0},{key:"Mod-Home",run:F5,shift:G5},{key:"End",run:xre,shift:Nre,preventDefault:!0},{key:"Mod-End",run:$5,shift:Y5},{key:"Enter",run:Q5,shift:Q5},{key:"Mod-a",run:jre},{key:"Backspace",run:e2,shift:e2,preventDefault:!0},{key:"Delete",run:Zq,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ej,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Fre,preventDefault:!0},{mac:"Mod-Backspace",run:Gre,preventDefault:!0},{mac:"Mod-Delete",run:Yre,preventDefault:!0}].concat(sse.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),ose=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:vre,shift:Mre},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bre,shift:Rre},{key:"Alt-ArrowUp",run:Wre},{key:"Shift-Alt-ArrowUp",run:Zre},{key:"Alt-ArrowDown",run:Kre},{key:"Shift-Alt-ArrowDown",run:Jre},{key:"Mod-Alt-ArrowUp",run:Hre},{key:"Mod-Alt-ArrowDown",run:Ure},{key:"Escape",run:Vre},{key:"Mod-Enter",run:nse},{key:"Alt-l",mac:"Ctrl-l",run:Ire},{key:"Mod-i",run:Pre,preventDefault:!0},{key:"Mod-[",run:sj},{key:"Mod-]",run:rj},{key:"Mod-Alt-\\",run:ise},{key:"Shift-Mod-k",run:ese},{key:"Shift-Mod-\\",run:Ore},{key:"Mod-/",run:Wie},{key:"Alt-A",run:Zie},{key:"Ctrl-m",mac:"Shift-Alt-m",run:rse}].concat(ase),lse={key:"Tab",run:rj,shift:sj},X5=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class bl{constructor(e,n,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?c=>s(X5(c)):X5,this.query=this.normalize(n)}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 In(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 n=iC(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=ir(e);let r=this.normalize(n);if(r.length)for(let s=0,o=i;;s++){let c=r.charCodeAt(s),u=this.match(c,o,this.bufferPos+this.bufferStart);if(s==r.length-1){if(u)return this.value=u,this;break}o==i&&s<n.length&&n.charCodeAt(s)==c&&o++}}}match(e,n,i){let r=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],c=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[s+1],to:i}:(this.matches[s]++,c=!0)),c||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:n,to:i}:this.matches.push(1,n)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}typeof Symbol<"u"&&(bl.prototype[Symbol.iterator]=function(){return this});const aj={from:-1,to:-1,match:/.*/.exec("")},NC="gm"+(/x/.unicode==null?"":"u");class oj{constructor(e,n,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=aj,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new lj(e,n,i,r,s);this.re=new RegExp(n,NC+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=Jd(e,r),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 n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let i=this.curLineStart+n.index,r=i+n[0].length;if(this.matchPos=Jd(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,match:n},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}}}const kw=new WeakMap;class ol{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,i){let r=kw.get(e);if(!r||r.from>=i||r.to<=n){let c=new ol(n,e.sliceString(n,i));return kw.set(e,c),c}if(r.from==n&&r.to==i)return r;let{text:s,from:o}=r;return o>n&&(s=e.sliceString(n,o)+s,o=n),r.to<i&&(s+=e.sliceString(r.to,i)),kw.set(e,new ol(o,s)),new ol(n,s.slice(n-o,i-o))}}class lj{constructor(e,n,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=aj,this.matchPos=Jd(e,r),this.re=new RegExp(n,NC+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=ol.get(e,r,this.chunkEnd(r+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,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let i=this.flat.from+n.index,r=i+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,match:n},this.matchPos=Jd(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ol.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(oj.prototype[Symbol.iterator]=lj.prototype[Symbol.iterator]=function(){return this});function cse(t){try{return new RegExp(t,NC),!0}catch{return!1}}function Jd(t,e){if(e>=t.length)return e;let n=t.lineAt(e),i;for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}const use=t=>{let{state:e}=t,n=String(e.doc.lineAt(t.state.selection.main.head).number),{close:i,result:r}=Tne(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:e.phrase("go")});return r.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){t.dispatch({effects:i});return}let c=e.doc.lineAt(e.selection.main.head),[,u,h,d,m]=o,g=d?+d.slice(1):0,y=h?+h:c.number;if(h&&m){let S=y/100;u&&(S=S*(u=="-"?-1:1)+c.number/e.doc.lines),y=Math.round(e.doc.lines*S)}else h&&u&&(y=y*(u=="-"?-1:1)+c.number);let x=e.doc.line(Math.max(1,Math.min(e.doc.lines,y))),w=de.cursor(x.from+Math.max(0,Math.min(g,x.length)));t.dispatch({effects:[i,Se.scrollIntoView(w.from,{y:"center"})],selection:w})}),!0},fse={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},hse=ke.define({combine(t){return pr(t,fse,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function dse(t){return[vse,yse]}const pse=Le.mark({class:"cm-selectionMatch"}),mse=Le.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function W5(t,e,n,i){return(n==0||t(e.sliceDoc(n-1,n))!=At.Word)&&(i==e.doc.length||t(e.sliceDoc(i,i+1))!=At.Word)}function gse(t,e,n,i){return t(e.sliceDoc(n,n+1))==At.Word&&t(e.sliceDoc(i-1,i))==At.Word}const yse=zt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(hse),{state:n}=t,i=n.selection;if(i.ranges.length>1)return Le.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return Le.none;let u=n.wordAt(r.head);if(!u)return Le.none;o=n.charCategorizer(r.head),s=n.sliceDoc(u.from,u.to)}else{let u=r.to-r.from;if(u<e.minSelectionLength||u>200)return Le.none;if(e.wholeWords){if(s=n.sliceDoc(r.from,r.to),o=n.charCategorizer(r.head),!(W5(o,n,r.from,r.to)&&gse(o,n,r.from,r.to)))return Le.none}else if(s=n.sliceDoc(r.from,r.to),!s)return Le.none}let c=[];for(let u of t.visibleRanges){let h=new bl(n.doc,s,u.from,u.to);for(;!h.next().done;){let{from:d,to:m}=h.value;if((!o||W5(o,n,d,m))&&(r.empty&&d<=r.from&&m>=r.to?c.push(mse.range(d,m)):(d>=r.to||m<=r.from)&&c.push(pse.range(d,m)),c.length>e.maxMatches))return Le.none}}return Le.set(c)}},{decorations:t=>t.decorations}),vse=Se.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),bse=({state:t,dispatch:e})=>{let{selection:n}=t,i=de.create(n.ranges.map(r=>t.wordAt(r.head)||de.cursor(r.head)),n.mainIndex);return i.eq(n)?!1:(e(t.update({selection:i})),!0)};function xse(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let o=!1,c=new bl(t.doc,e,i[i.length-1].to);;)if(c.next(),c.done){if(o)return null;c=new bl(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(u=>u.from==c.value.from))continue;if(s){let u=t.wordAt(c.value.from);if(!u||u.from!=c.value.from||u.to!=c.value.to)continue}return c.value}}const wse=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return bse({state:t,dispatch:e});let i=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=i))return!1;let r=xse(t,i);return r?(e(t.update({selection:t.selection.addRange(de.range(r.from,r.to),!1),effects:Se.scrollIntoView(r.to)})),!0):!1},Tl=ke.define({combine(t){return pr(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zse(e),scrollToMatch:e=>Se.scrollIntoView(e)})}});class cj{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||cse(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,(n,i)=>i=="n"?`
|
|
51
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ose(this):new kse(this)}getCursor(e,n=0,i){let r=e.doc?e:Je.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Ho(this,r,n,i):Po(this,r,n,i)}}class uj{constructor(e){this.spec=e}}function Sse(t,e,n){return(i,r,s,o)=>{if(n&&!n(i,r,s,o))return!1;let c=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return t(c,e,i,r)}}function Po(t,e,n,i){let r;return t.wholeWord&&(r=Cse(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(r=Sse(t.test,e,r)),new bl(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Cse(t,e){return(n,i,r,s)=>((s>n||s+r.length<i)&&(s=Math.max(0,n-2),r=t.sliceString(s,Math.min(t.length,i+2))),(e(ep(r,n-s))!=At.Word||e(tp(r,n-s))!=At.Word)&&(e(tp(r,i-s))!=At.Word||e(ep(r,i-s))!=At.Word))}class kse extends uj{constructor(e){super(e)}nextMatch(e,n,i){let r=Po(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Po(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==i?null:r.value}prevMatchInRange(e,n,i){for(let r=i;;){let s=Math.max(n,r-1e4-this.spec.unquoted.length),o=Po(this.spec,e,s,r),c=null;for(;!o.nextOverlapping().done;)c=o.value;if(c)return c;if(s==n)return null;r-=1e4}}prevMatch(e,n,i){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let i=Po(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Po(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Ase(t,e,n){return(i,r,s)=>(!n||n(i,r,s))&&t(s[0],e,i,r)}function Ho(t,e,n,i){let r;return t.wholeWord&&(r=_se(e.charCategorizer(e.selection.main.head))),t.test&&(r=Ase(t.test,e,r)),new oj(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},n,i)}function ep(t,e){return t.slice(sn(t,e,!1),e)}function tp(t,e){return t.slice(e,sn(t,e))}function _se(t){return(e,n,i)=>!i[0].length||(t(ep(i.input,i.index))!=At.Word||t(tp(i.input,i.index))!=At.Word)&&(t(tp(i.input,i.index+i[0].length))!=At.Word||t(ep(i.input,i.index+i[0].length))!=At.Word)}class Ose extends uj{nextMatch(e,n,i){let r=Ho(this.spec,e,i,e.doc.length).next();return r.done&&(r=Ho(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),o=Ho(this.spec,e,s,i),c=null;for(;!o.next().done;)c=o.value;if(c&&(s==n||c.from>s+10))return c;if(s==n)return null}}prevMatch(e,n,i){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+i.slice(r)}return n})}matchAll(e,n){let i=Ho(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Ho(this.spec,e,Math.max(0,n-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const ku=je.define(),DC=je.define(),Vs=_n.define({create(t){return new Aw(t2(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ku)?t=new Aw(n.value.create(),t.panel):n.is(DC)&&(t=new Aw(t.query,n.value?LC:null));return t},provide:t=>xu.from(t,e=>e.panel)});class Aw{constructor(e,n){this.query=e,this.panel=n}}const Ese=Le.mark({class:"cm-searchMatch"}),Tse=Le.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Mse=zt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Vs))}update(t){let e=t.state.field(Vs);(e!=t.startState.field(Vs)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Le.none;let{view:n}=this,i=new Kr;for(let r=0,s=n.visibleRanges,o=s.length;r<o;r++){let{from:c,to:u}=s[r];for(;r<o-1&&u>s[r+1].from-500;)u=s[++r].to;t.highlight(n.state,c,u,(h,d)=>{let m=n.state.selection.ranges.some(g=>g.from==h&&g.to==d);i.add(h,d,m?Tse:Ese)})}return i.finish()}},{decorations:t=>t.decorations});function Yu(t){return e=>{let n=e.state.field(Vs,!1);return n&&n.query.spec.valid?t(e,n):dj(e)}}const np=Yu((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=de.single(i.from,i.to),s=t.state.facet(Tl);return t.dispatch({selection:r,effects:[zC(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),hj(t),!0}),ip=Yu((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=de.single(r.from,r.to),o=t.state.facet(Tl);return t.dispatch({selection:s,effects:[zC(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),hj(t),!0}),Rse=Yu((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:de.create(n.map(i=>de.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Nse=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let c=new bl(t.doc,t.sliceDoc(i,r));!c.next().done;){if(s.length>1e3)return!1;c.value.from==i&&(o=s.length),s.push(de.range(c.value.from,c.value.to))}return e(t.update({selection:de.create(s,o),userEvent:"select.search.matches"})),!0},K5=Yu((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,c=[],u,h,d=[];o.from==i&&o.to==r&&(h=n.toText(e.getReplacement(o)),c.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(n,o.from,o.to),d.push(Se.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let m=t.state.changes(c);return o&&(u=de.single(o.from,o.to).map(m),d.push(zC(t,o)),d.push(n.facet(Tl).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:d,userEvent:"input.replace"}),!0}),Dse=Yu((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:Se.announce.of(i),userEvent:"input.replace.all"}),!0});function LC(t){return t.state.facet(Tl).createPanel(t)}function t2(t,e){var n,i,r,s,o;let c=t.selection.main,u=c.empty||c.to>c.from+100?"":t.sliceDoc(c.from,c.to);if(e&&!u)return e;let h=t.facet(Tl);return new cj({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function fj(t){let e=wC(t,LC);return e&&e.dom.querySelector("[main-field]")}function hj(t){let e=fj(t);e&&e==t.root.activeElement&&e.select()}const dj=t=>{let e=t.state.field(Vs,!1);if(e&&e.panel){let n=fj(t);if(n&&n!=t.root.activeElement){let i=t2(t.state,e.query.spec);i.valid&&t.dispatch({effects:ku.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[DC.of(!0),e?ku.of(t2(t.state,e.query.spec)):je.appendConfig.of(qse)]});return!0},pj=t=>{let e=t.state.field(Vs,!1);if(!e||!e.panel)return!1;let n=wC(t,LC);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:DC.of(!1)}),!0},Lse=[{key:"Mod-f",run:dj,scope:"editor search-panel"},{key:"F3",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Nse},{key:"Mod-Alt-g",run:use},{key:"Mod-d",run:wse,preventDefault:!0}];class zse{constructor(e){this.view=e;let n=this.query=e.state.field(Vs).query.spec;this.commit=this.commit.bind(this),this.searchField=dt("input",{value:n.search,placeholder:ri(e,"Find"),"aria-label":ri(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=dt("input",{value:n.replace,placeholder:ri(e,"Replace"),"aria-label":ri(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=dt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=dt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=dt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,o){return dt("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=dt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>np(e),[ri(e,"next")]),i("prev",()=>ip(e),[ri(e,"previous")]),i("select",()=>Rse(e),[ri(e,"all")]),dt("label",null,[this.caseField,ri(e,"match case")]),dt("label",null,[this.reField,ri(e,"regexp")]),dt("label",null,[this.wordField,ri(e,"by word")]),...e.state.readOnly?[]:[dt("br"),this.replaceField,i("replace",()=>K5(e),[ri(e,"replace")]),i("replaceAll",()=>Dse(e),[ri(e,"replace all")])],dt("button",{name:"close",onclick:()=>pj(e),"aria-label":ri(e,"close"),type:"button"},["×"])])}commit(){let e=new cj({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ku.of(e)}))}keydown(e){Ite(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ip:np)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),K5(this.view))}update(e){for(let n of e.transactions)for(let i of n.effects)i.is(ku)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Tl).top}}function ri(t,e){return t.state.phrase(e)}const Kh=30,Zh=/[\s\.,:;?!]/;function zC(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-Kh),o=Math.min(r,n+Kh),c=t.state.sliceDoc(s,o);if(s!=i.from){for(let u=0;u<Kh;u++)if(!Zh.test(c[u+1])&&Zh.test(c[u])){c=c.slice(u);break}}if(o!=r){for(let u=c.length-1;u>c.length-Kh;u--)if(!Zh.test(c[u-1])&&Zh.test(c[u])){c=c.slice(0,u);break}}return Se.announce.of(`${t.state.phrase("current match")}. ${c} ${t.state.phrase("on line")} ${i.number}.`)}const Bse=Se.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),qse=[Vs,Za.low(Mse),Bse];class mj{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Cn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(gj(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Z5(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jse(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=Z5(e)+Z5(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Ise(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:jse(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class J5{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function Ia(t){return t.selection.main.from}function gj(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const yj=dr.define();function Pse(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(c=>{if(c!=r&&n!=i&&t.sliceDoc(c.from+s,c.from+o)!=t.sliceDoc(n,i))return{range:c};let u=t.toText(e);return{changes:{from:c.from+s,to:i==r.from?c.to:c.from+o,insert:u},range:de.cursor(c.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const e4=new WeakMap;function Hse(t){if(!Array.isArray(t))return t;let e=e4.get(t);return e||e4.set(t,e=Ise(t)),e}const rp=je.define(),Au=je.define();class Use{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=In(e,n),r=ir(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(In(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let A=In(e,0),O=ir(A),E=O==e.length?0:-100;if(A!=n[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,O])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=n.length,h=0;if(c<0){for(let A=0,O=Math.min(e.length,200);A<O&&h<u;){let E=In(e,A);(E==n[h]||E==i[h])&&(r[h++]=A),A+=ir(E)}if(h<u)return null}let d=0,m=0,g=!1,y=0,x=-1,w=-1,S=/[a-z]/.test(e),C=!0;for(let A=0,O=Math.min(e.length,200),E=0;A<O&&m<u;){let T=In(e,A);c<0&&(d<u&&T==n[d]&&(s[d++]=A),y<u&&(T==n[y]||T==i[y]?(y==0&&(x=A),w=A+1,y++):y=0));let M,R=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(M=iC(T))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||R==1&&S||E==0&&R!=0)&&(n[m]==T||i[m]==T&&(g=!0)?o[m++]=A:o.length&&(C=!1)),E=R,A+=ir(T)}return m==u&&o[0]==0&&C?this.result(-100+(g?-200:0),o,e):y==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):y==u?this.ret(-900-e.length,[x,w]):m==u?this.result(-100+(g?-200:0)+-700+(C?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let c=o+(this.astral?ir(In(i,o)):1);s&&r[s-1]==o?r[s-1]=c:(r[s++]=o,r[s++]=c)}return this.ret(e-i.length,r)}}class Vse{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const rn=ke.define({combine(t){return pr(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Fse,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>t4(e(i),n(i)),optionClass:(e,n)=>i=>t4(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function t4(t,e){return t?e?t+" "+e:t:e}function Fse(t,e,n,i,r,s){let o=t.textDirection==yt.RTL,c=o,u=!1,h="top",d,m,g=e.left-r.left,y=r.right-e.right,x=i.right-i.left,w=i.bottom-i.top;if(c&&g<Math.min(x,y)?c=!1:!c&&y<Math.min(x,g)&&(c=!0),x<=(c?g:y))d=Math.max(r.top,Math.min(n.top,r.bottom-w))-e.top,m=Math.min(400,c?g:y);else{u=!0,m=Math.min(400,(o?e.right:r.right-e.left)-30);let A=r.bottom-e.bottom;A>=w||A>e.top?d=n.bottom-e.top:(h="bottom",d=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,C=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${d/S}px; max-width: ${m/C}px`,class:"cm-completionInfo-"+(u?o?"left-narrow":"right-narrow":c?"left":"right")}}const BC=je.define();function $se(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let c=n.displayLabel||n.label,u=0;for(let h=0;h<s.length;){let d=s[h++],m=s[h++];d>u&&o.appendChild(document.createTextNode(c.slice(u,d)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(d,m))),g.className="cm-completionMatchedText",u=m}return u<c.length&&o.appendChild(document.createTextNode(c.slice(u))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function _w(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class Gse{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,c=e.state.facet(rn);this.optionContent=$se(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=_w(s.length,o,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:h}=e.state.field(n).open;for(let d=u.target,m;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(m=/-(\d+)$/.exec(d.id))&&+m[1]<h.length){this.applyCompletion(e,h[+m[1]]),u.preventDefault();return}if(u.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&u.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&u.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:BC.of(d)}),u.preventDefault())}}),this.dom.addEventListener("focusout",u=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(rn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Au.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:c}=i.open;(!r.open||r.open.options!=s)&&(this.range=_w(s.length,o,e.state.facet(rn).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),c!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=_w(n.options.length,n.selected,this.view.state.facet(rn).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,r)}).catch(c=>Fn(this.view.state,c,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&Qse(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(rn).positionInfo(this.view,n,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:c,match:u}=e[o],{section:h}=c;if(h){let g=typeof h=="string"?h:h.name;if(g!=s&&(o>i.from||i.from==0))if(s=g,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let y=r.appendChild(document.createElement("completion-section"));y.textContent=g}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let m=this.optionClass(c);m&&(d.className=m);for(let g of this.optionContent){let y=g(c,this.view.state,this.view,u);y&&d.appendChild(y)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Yse(t,e){return n=>new Gse(n,t,e)}function Qse(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function n4(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Xse(t,e){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:m}=d.completion;if(m){i||(i=[]);let g=typeof m=="string"?m:m.name;i.some(y=>y.name==g)||i.push(typeof m=="string"?{name:g}:m)}},o=e.facet(rn);for(let d of t)if(d.hasResult()){let m=d.result.getMatch;if(d.result.filter===!1)for(let g of d.result.options)s(new J5(g,d.source,m?m(g):[],1e9-n.length));else{let g=e.sliceDoc(d.from,d.to),y,x=o.filterStrict?new Vse(g):new Use(g);for(let w of d.result.options)if(y=x.match(w.label)){let S=w.displayLabel?m?m(w,y.matched):[]:y.matched,C=y.score+(w.boost||0);if(s(new J5(w,d.source,S,C)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:A}=w.section;r||(r=Object.create(null)),r[A]=Math.max(C,r[A]||-1e9)}}}}if(i){let d=Object.create(null),m=0,g=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?r[x.name]-r[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name<x.name?-1:1);for(let y of i.sort(g))m-=1e5,d[y.name]=m;for(let y of n){let{section:x}=y.completion;x&&(y.score+=d[typeof x=="string"?x:x.name])}}let c=[],u=null,h=o.compareCompletions;for(let d of n.sort((m,g)=>g.score-m.score||h(m.completion,g.completion))){let m=d.completion;!u||u.label!=m.label||u.detail!=m.detail||u.type!=null&&m.type!=null&&u.type!=m.type||u.apply!=m.apply||u.boost!=m.boost?c.push(d):n4(d.completion)>n4(u)&&(c[c.length-1]=d),u=d.completion}return c}class Ko{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Ko(this.options,i4(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let c=Xse(e,n);if(!c.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let u=n.facet(rn).selectOnOpen?0:-1;if(r&&r.selected!=u&&r.selected!=-1){let h=r.options[r.selected].completion;for(let d=0;d<c.length;d++)if(c[d].completion==h){u=d;break}}return new Ko(c,i4(i,u),{pos:e.reduce((h,d)=>d.hasResult()?Math.min(h,d.from):h,1e8),create:tae,above:s.aboveCursor},r?r.timestamp:Date.now(),u,!1)}map(e){return new Ko(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ko(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sp{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new sp(Jse,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(rn),s=(i.override||n.languageDataAt("autocomplete",Ia(n)).map(Hse)).map(u=>(this.active.find(d=>d.source==u)||new Ai(u,this.active.some(d=>d.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((u,h)=>u==this.active[h])&&(s=this.active);let o=this.open,c=e.effects.some(u=>u.is(qC));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!Wse(s,this.active)||c?o=Ko.build(s,n,this.id,o,i,c):o&&o.disabled&&!s.some(u=>u.isPending)&&(o=null),!o&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new Ai(u.source,0):u));for(let u of e.effects)u.is(BC)&&(o=o&&o.setSelected(u.value,this.id));return s==this.active&&o==this.open?this:new sp(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kse:Zse}}function Wse(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const Kse={"aria-autocomplete":"list"},Zse={};function i4(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Jse=[];function vj(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(yj);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=vj(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Ai(r.source,0)),i&4&&r.state==0&&(r=new Ai(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(rp))r=new Ai(r.source,1,s.value);else if(s.is(Au))r=new Ai(r.source,0);else if(s.is(qC))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ia(e.state))}}class ll extends Ai{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),c=Ia(e.state);if(c>o||!r||n&2&&(Ia(e.startState)==this.from||c<this.limit))return new Ai(this.source,n&4?1:0);let u=e.changes.mapPos(this.limit);return eae(r.validFor,e.state,s,o)?new ll(this.source,this.explicit,u,r,s,o):r.update&&(r=r.update(r,s,o,new mj(e.state,c,!1)))?new ll(this.source,this.explicit,u,r,r.from,(i=r.to)!==null&&i!==void 0?i:Ia(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ll(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function eae(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):gj(t,!0).test(r)}const qC=je.define({map(t,e){return t.map(n=>n.map(e))}}),Pn=_n.define({create(){return sp.start()},update(t,e){return t.update(e)},provide:t=>[xC.from(t,e=>e.tooltip),Se.contentAttributes.from(t,e=>e.attrs)]});function jC(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(Pn).active.find(r=>r.source==e.source);return i instanceof ll?(typeof n=="string"?t.dispatch({...Pse(t.state,n,i.from,i.to),annotations:yj.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const tae=Yse(Pn,jC);function Jh(t,e="option"){return n=>{let i=n.state.field(Pn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(rn).interactionDelay)return!1;let r=1,s;e=="page"&&(s=K6(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,c=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return c<0?c=e=="page"?0:o-1:c>=o&&(c=e=="page"?o-1:0),n.dispatch({effects:BC.of(c)}),!0}}const nae=t=>{let e=t.state.field(Pn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(rn).interactionDelay?!1:jC(t,e.open.options[e.open.selected])},Ow=t=>t.state.field(Pn,!1)?(t.dispatch({effects:rp.of(!0)}),!0):!1,iae=t=>{let e=t.state.field(Pn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Au.of(null)}),!0)};class rae{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const sae=50,aae=1e3,oae=zt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Pn).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Pn),n=t.state.facet(rn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Pn)==e)return;let i=t.transactions.some(s=>{let o=vj(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>sae&&Date.now()-o.time>aae){for(let c of o.context.abortListeners)try{c()}catch(u){Fn(this.view.state,u)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(rp)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Pn);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Ia(e),i=new mj(e,n,t.explicit,this.view),r=new rae(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Au.of(null)}),Fn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(rn),i=this.view.state.field(Pn);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let c=Ia(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(c,s.done.from+(s.active.explicit?0:1)),h=new ll(s.active.source,s.active.explicit,u,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:c);for(let d of s.updates)h=h.update(d,n);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(c=>c.source==s.active.source);if(o&&o.isPending)if(s.done==null){let c=new Ai(s.active.source,0);for(let u of s.updates)c=c.update(u,n);c.isPending||e.push(c)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qC.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Pn,!1);if(e&&e.tooltip&&this.view.state.facet(rn).closeOnBlur){let n=e.open&&K6(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Au.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rp.of(!1)}),20),this.composing=0}}}),lae=typeof navigator=="object"&&/Win/.test(navigator.platform),cae=Za.highest(Se.domEventHandlers({keydown(t,e){let n=e.state.field(Pn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(lae&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&jC(e,i),!1}})),uae=Se.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),_u={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},La=je.define({map(t,e){let n=e.mapPos(t,-1,Rn.TrackAfter);return n??void 0}}),IC=new class extends Gs{};IC.startSide=1;IC.endSide=-1;const bj=_n.define({create(){return Ye.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of e.effects)n.is(La)&&(t=t.update({add:[IC.range(n.value,n.value+1)]}));return t}});function fae(){return[dae,bj]}const Ew="()[]{}<>«»»«[]{}";function xj(t){for(let e=0;e<Ew.length;e+=2)if(Ew.charCodeAt(e)==t)return Ew.charAt(e+1);return iC(t<128?t:t+1)}function wj(t,e){return t.languageDataAt("closeBrackets",e)[0]||_u}const hae=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dae=Se.inputHandler.of((t,e,n,i)=>{if((hae?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||i.length==2&&ir(In(i,0))==1||e!=r.from||n!=r.to)return!1;let s=gae(t.state,i);return s?(t.dispatch(s),!0):!1}),pae=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=wj(t,t.selection.main.head).brackets||_u.brackets,r=null,s=t.changeByRange(o=>{if(o.empty){let c=yae(t.doc,o.head);for(let u of i)if(u==c&&Wp(t.doc,o.head)==xj(In(u,0)))return{changes:{from:o.head-u.length,to:o.head+u.length},range:de.cursor(o.head-u.length)}}return{range:r=o}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mae=[{key:"Backspace",run:pae}];function gae(t,e){let n=wj(t,t.selection.main.head),i=n.brackets||_u.brackets;for(let r of i){let s=xj(In(r,0));if(e==r)return s==r?xae(t,r,i.indexOf(r+r+r)>-1,n):vae(t,r,s,n.before||_u.before);if(e==s&&Sj(t,t.selection.main.from))return bae(t,r,s)}return null}function Sj(t,e){let n=!1;return t.field(bj).between(0,t.doc.length,i=>{i==e&&(n=!0)}),n}function Wp(t,e){let n=t.sliceString(e,e+2);return n.slice(0,ir(In(n,0)))}function yae(t,e){let n=t.sliceString(e-2,e);return ir(In(n,0))==n.length?n:n.slice(1)}function vae(t,e,n,i){let r=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:La.of(o.to+e.length),range:de.range(o.anchor+e.length,o.head+e.length)};let c=Wp(t.doc,o.head);return!c||/\s/.test(c)||i.indexOf(c)>-1?{changes:{insert:e+n,from:o.head},effects:La.of(o.head+e.length),range:de.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bae(t,e,n){let i=null,r=t.changeByRange(s=>s.empty&&Wp(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:de.cursor(s.head+n.length)}:i={range:s});return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function xae(t,e,n,i){let r=i.stringPrefixes||_u.stringPrefixes,s=null,o=t.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:La.of(c.to+e.length),range:de.range(c.anchor+e.length,c.head+e.length)};let u=c.head,h=Wp(t.doc,u),d;if(h==e){if(r4(t,u))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(Sj(t,u)){let g=n&&t.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:de.cursor(u+g.length)}}}else{if(n&&t.sliceDoc(u-2*e.length,u)==e+e&&(d=s4(t,u-2*e.length,r))>-1&&r4(t,d))return{changes:{insert:e+e+e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(t.charCategorizer(u)(h)!=At.Word&&s4(t,u,r)>-1&&!wae(t,u,e,r))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)}}return{range:s=c}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function r4(t,e){let n=Cn(t).resolveInner(e+1);return n.parent&&n.from==e}function wae(t,e,n,i){let r=Cn(t).resolveInner(e,-1),s=i.reduce((o,c)=>Math.max(o,c.length),0);for(let o=0;o<5;o++){let c=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),u=c.indexOf(n);if(!u||u>-1&&i.indexOf(c.slice(0,u))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+u;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function s4(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=At.Word)return e;for(let r of n){let s=e-r.length;if(t.sliceDoc(s,e)==r&&i(t.sliceDoc(s-1,s))!=At.Word)return s}return-1}function Sae(t={}){return[cae,Pn,rn.of(t),oae,Cae,uae]}const Cj=[{key:"Ctrl-Space",run:Ow},{mac:"Alt-`",run:Ow},{mac:"Alt-i",run:Ow},{key:"Escape",run:iae},{key:"ArrowDown",run:Jh(!0)},{key:"ArrowUp",run:Jh(!1)},{key:"PageDown",run:Jh(!0,"page")},{key:"PageUp",run:Jh(!1,"page")},{key:"Enter",run:nae}],Cae=Za.highest(Hp.computeN([rn],t=>t.facet(rn).defaultKeymap?[Cj]:[]));class a4{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class Ea{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let r=i.facet(Ou).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),o=new Kr,c=[],u=0,h=i.doc.iter(),d=0,m=i.doc.length;for(let y=0;;){let x=y==s.length?null:s[y];if(!x&&!c.length)break;let w,S;if(c.length)w=u,S=c.reduce((O,E)=>Math.min(O,E.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>m)break;S=x.to,c.push(x),y++}for(;y<s.length;){let O=s[y];if(O.from==w&&(O.to>O.from||O.to==w))c.push(O),y++,S=Math.min(O.to,S);else{S=Math.min(O.from,S);break}}S=Math.min(S,m);let C=!1;if(c.some(O=>O.from==w&&(O.to==S||S==m))&&(C=w==S,!C&&S-w<10)){let O=w-(d+h.value.length);O>0&&(h.next(O),d=w);for(let E=w;;){if(E>=S){C=!0;break}if(!h.lineBreak&&d+h.value.length>E)break;E=d+h.value.length,d+=h.value.length,h.next()}}let A=Bae(c);if(C)o.add(w,w,Le.widget({widget:new Nae(A),diagnostics:c.slice()}));else{let O=c.reduce((E,T)=>T.markClass?E+" "+T.markClass:E,"");o.add(w,S,Le.mark({class:"cm-lintRange cm-lintRange-"+A+O,diagnostics:c.slice(),inclusiveEnd:c.some(E=>E.to>S)}))}if(u=S,u==m)break;for(let O=0;O<c.length;O++)c[O].to<=u&&c.splice(O--,1)}let g=o.finish();return new Ea(g,n,Zs(g))}}function Zs(t,e=null,n=0){let i=null;return t.between(n,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new a4(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new a4(i.from,s,i.diagnostic)}}),i}function kae(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(Ou).hideOn(t,n,i);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(kj))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function Aae(t,e){return t.field(oi,!1)?e:e.concat(je.appendConfig.of(qae))}const kj=je.define(),PC=je.define(),Aj=je.define(),oi=_n.define({create(){return new Ea(Le.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=Zs(n,t.selected.diagnostic,s)||Zs(n,null,s)}!n.size&&r&&e.state.facet(Ou).autoPanel&&(r=null),t=new Ea(n,r,i)}for(let n of e.effects)if(n.is(kj)){let i=e.state.facet(Ou).autoPanel?n.value.length?Eu.open:null:t.panel;t=Ea.init(n.value,i,e.state)}else n.is(PC)?t=new Ea(t.diagnostics,n.value?Eu.open:null,t.selected):n.is(Aj)&&(t=new Ea(t.diagnostics,t.panel,n.value));return t},provide:t=>[xu.from(t,e=>e.panel),Se.decorations.from(t,e=>e.diagnostics)]}),_ae=Le.mark({class:"cm-lintRange cm-lintRange-active"});function Oae(t,e,n){let{diagnostics:i}=t.state.field(oi),r,s=-1,o=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(u,h,{spec:d})=>{if(e>=u&&e<=h&&(u==h||(e>u||n>0)&&(e<h||n<0)))return r=d.diagnostics,s=u,o=h,!1});let c=t.state.facet(Ou).tooltipFilter;return r&&c&&(r=c(r,t.state)),r?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Eae(t,r)}}}:null}function Eae(t,e){return dt("ul",{class:"cm-tooltip-lint"},e.map(n=>Oj(t,n,!1)))}const Tae=t=>{let e=t.state.field(oi,!1);(!e||!e.panel)&&t.dispatch({effects:Aae(t.state,[PC.of(!0)])});let n=wC(t,Eu.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},o4=t=>{let e=t.state.field(oi,!1);return!e||!e.panel?!1:(t.dispatch({effects:PC.of(!1)}),!0)},Mae=t=>{let e=t.state.field(oi,!1);if(!e)return!1;let n=t.state.selection.main,i=Zs(e.diagnostics,null,n.to+1);return!i&&(i=Zs(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Rae=[{key:"Mod-Shift-m",run:Tae,preventDefault:!0},{key:"F8",run:Mae}],Ou=ke.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...pr(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:l4,tooltipFilter:l4,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,r,s)=>e(i,r,s)||n(i,r,s):e:n,autoPanel:(e,n)=>e||n})}}});function l4(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function _j(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let r=n[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Oj(t,e,n){var i;let r=n?_j(e.actions):[];return dt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},dt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let c=!1,u=y=>{if(y.preventDefault(),c)return;c=!0;let x=Zs(t.state.field(oi).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:h}=s,d=r[o]?h.indexOf(r[o]):-1,m=d<0?h:[h.slice(0,d),dt("u",h.slice(d,d+1)),h.slice(d+1)],g=s.markClass?" "+s.markClass:"";return dt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${h}${d<0?"":` (access key "${r[o]})"`}.`},m)}),e.source&&dt("div",{class:"cm-diagnosticSource"},e.source))}class Nae extends mr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return dt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class c4{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Oj(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Eu{constructor(e){this.view=e,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)o4(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=_j(s.actions);for(let c=0;c<o.length;c++)if(o[c].toUpperCase().charCodeAt(0)==r.keyCode){let u=Zs(this.view.state.field(oi).diagnostics,s);u&&s.actions[c].apply(e,u.from,u.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=dt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=dt("div",{class:"cm-panel-lint"},this.list,dt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>o4(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(oi).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(oi),i=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(c,u,{spec:h})=>{for(let d of h.diagnostics){if(o.has(d))continue;o.add(d);let m=-1,g;for(let y=i;y<this.items.length;y++)if(this.items[y].diagnostic==d){m=y;break}m<0?(g=new c4(this.view,d),this.items.splice(i,0,g),r=!0):(g=this.items[m],m>i&&(this.items.splice(i,m-i),r=!0)),n&&g.diagnostic==n.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new c4(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:c,panel:u})=>{let h=u.height/this.list.offsetHeight;c.top<u.top?this.list.scrollTop-=(u.top-c.top)/h:c.bottom>u.bottom&&(this.list.scrollTop+=(c.bottom-u.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(oi),i=Zs(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Aj.of(i)})}static open(e){return new Eu(e)}}function Dae(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function ed(t){return Dae(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Lae=Se.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:ed("#d11")},".cm-lintRange-warning":{backgroundImage:ed("orange")},".cm-lintRange-info":{backgroundImage:ed("#999")},".cm-lintRange-hint":{backgroundImage:ed("#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 zae(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Bae(t){let e="hint",n=1;for(let i of t){let r=zae(i.severity);r>n&&(n=r,e=i.severity)}return e}const qae=[oi,Se.decorations.compute([oi],t=>{let{selected:e,panel:n}=t.field(oi);return!e||!n||e.from==e.to?Le.none:Le.set([_ae.range(e.from,e.to)])}),One(Oae,{hideOn:kae}),Lae];var u4=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(mae)),e.defaultKeymap!==!1&&(i=i.concat(ose)),e.searchKeymap!==!1&&(i=i.concat(Lse)),e.historyKeymap!==!1&&(i=i.concat(pre)),e.foldKeymap!==!1&&(i=i.concat(Eie)),e.completionKeymap!==!1&&(i=i.concat(Cj)),e.lintKeymap!==!1&&(i=i.concat(Rae));var r=[];return e.lineNumbers!==!1&&r.push(Pne()),e.highlightActiveLineGutter!==!1&&r.push(Vne()),e.highlightSpecialChars!==!1&&r.push(nne()),e.history!==!1&&r.push(sre()),e.foldGutter!==!1&&r.push(Nie()),e.drawSelection!==!1&&r.push($te()),e.dropCursor!==!1&&r.push(Wte()),e.allowMultipleSelections!==!1&&r.push(Je.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(vie()),e.syntaxHighlighting!==!1&&r.push(kq(Bie,{fallback:!0})),e.bracketMatching!==!1&&r.push(Vie()),e.closeBrackets!==!1&&r.push(fae()),e.autocompletion!==!1&&r.push(Sae()),e.rectangularSelection!==!1&&r.push(gne()),n!==!1&&r.push(bne()),e.highlightActiveLine!==!1&&r.push(lne()),e.highlightSelectionMatches!==!1&&r.push(dse()),e.tabSize&&typeof e.tabSize=="number"&&r.push(Vp.of(" ".repeat(e.tabSize))),r.concat([Hp.of(i.flat())]).filter(Boolean)};const jae="#e5c07b",f4="#e06c75",Iae="#56b6c2",Pae="#ffffff",dd="#abb2bf",n2="#7d8799",Hae="#61afef",Uae="#98c379",h4="#d19a66",Vae="#c678dd",Fae="#21252b",d4="#2c313a",p4="#282c34",Tw="#353a42",$ae="#3E4451",m4="#528bff",Gae=Se.theme({"&":{color:dd,backgroundColor:p4},".cm-content":{caretColor:m4},".cm-cursor, .cm-dropCursor":{borderLeftColor:m4},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$ae},".cm-panels":{backgroundColor:Fae,color:dd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:p4,color:n2,border:"none"},".cm-activeLineGutter":{backgroundColor:d4},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Tw},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Tw,borderBottomColor:Tw},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:d4,color:dd}}},{dark:!0}),Yae=$u.define([{tag:le.keyword,color:Vae},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:f4},{tag:[le.function(le.variableName),le.labelName],color:Hae},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:h4},{tag:[le.definition(le.name),le.separator],color:dd},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:jae},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:Iae},{tag:[le.meta,le.comment],color:n2},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:n2,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:f4},{tag:[le.atom,le.bool,le.special(le.variableName)],color:h4},{tag:[le.processingInstruction,le.string,le.inserted],color:Uae},{tag:le.invalid,color:Pae}]),Ej=[Gae,kq(Yae)];var Qae=Se.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Xae=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:c=!0}=e,u=[];switch(n&&u.unshift(Hp.of([lse])),c&&(typeof c=="boolean"?u.unshift(u4()):u.unshift(u4(c))),o&&u.unshift(hne(o)),s){case"light":u.push(Qae);break;case"dark":u.push(Ej);break;case"none":break;default:u.push(s);break}return i===!1&&u.push(Se.editable.of(!1)),r&&u.push(Je.readOnly.of(!0)),[...u]},Wae=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Kae{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class g4{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Mw=null,Zae=()=>typeof window>"u"?new g4:(Mw||(Mw=new g4),Mw),y4=dr.define(),Jae=200,eoe=[];function toe(t){var{value:e,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:c=eoe,autoFocus:u,theme:h="light",height:d=null,minHeight:m=null,maxHeight:g=null,width:y=null,minWidth:x=null,maxWidth:w=null,placeholder:S="",editable:C=!0,readOnly:A=!1,indentWithTab:O=!0,basicSetup:E=!0,root:T,initialState:M}=t,[R,z]=j.useState(),[q,U]=j.useState(),[P,$]=j.useState(),K=j.useState(()=>({current:null}))[0],L=j.useState(()=>({current:null}))[0],Y=Se.theme({"&":{height:d,minHeight:m,maxHeight:g,width:y,minWidth:x,maxWidth:w},"& .cm-scroller":{height:"100% !important"}}),D=Se.updateListener.of(G=>{if(G.docChanged&&typeof i=="function"&&!G.transactions.some(F=>F.annotation(y4))){K.current?K.current.reset():(K.current=new Kae(()=>{if(L.current){var F=L.current;L.current=null,F()}K.current=null},Jae),Zae().add(K.current));var W=G.state.doc,B=W.toString();i(B,G)}r&&r(Wae(G))}),Q=Xae({theme:h,editable:C,readOnly:A,placeholder:S,indentWithTab:O,basicSetup:E}),ee=[D,Y,...Q];return o&&typeof o=="function"&&ee.push(Se.updateListener.of(o)),ee=ee.concat(c),j.useLayoutEffect(()=>{if(R&&!P){var G={doc:e,selection:n,extensions:ee},W=M?Je.fromJSON(M.json,G,M.fields):Je.create(G);if($(W),!q){var B=new Se({state:W,parent:R,root:T});U(B),s&&s(B,W)}}return()=>{q&&($(void 0),U(void 0))}},[R,P]),j.useEffect(()=>{t.container&&z(t.container)},[t.container]),j.useEffect(()=>()=>{q&&(q.destroy(),U(void 0)),K.current&&(K.current.cancel(),K.current=null)},[q]),j.useEffect(()=>{u&&q&&q.focus()},[u,q]),j.useEffect(()=>{q&&q.dispatch({effects:je.reconfigure.of(ee)})},[h,c,d,m,g,y,x,w,S,C,A,O,E,i,o]),j.useEffect(()=>{if(e!==void 0){var G=q?q.state.doc.toString():"";if(q&&e!==G){var W=K.current&&!K.current.isDone,B=()=>{q&&e!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:e||""},annotations:[y4.of(!0)]})};W?L.current=B:B()}}},[e,q]),{state:P,setState:$,view:q,setView:U,container:R,setContainer:z}}var noe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Tj=j.forwardRef((t,e)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:m="light",height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,root:R,initialState:z}=t,q=NJ(t,noe),U=j.useRef(null),{state:P,view:$,container:K,setContainer:L}=toe({root:R,value:i,autoFocus:d,theme:m,height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,selection:r,onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:s,initialState:z});j.useImperativeHandle(e,()=>({editor:U.current,state:P,view:$}),[U,K,P,$]);var Y=j.useCallback(Q=>{U.current=Q,L(Q)},[L]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return k.jsx("div",cS({ref:Y,className:""+D+(n?" "+n:"")},q))});Tj.displayName="CodeMirror";var v4={};class ap{constructor(e,n,i,r,s,o,c,u,h,d=0,m){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=c,this.bufferBase=u,this.curContext=h,this.lookAhead=d,this.parent=m}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new ap(e,[],n,i,i,0,[],0,r?new b4(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),c=s.dynamicPrecedence(r);if(c&&(this.score+=c),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let u=this.stack.length-(i-1)*3-(e&262144?6:0),h=u?this.stack[u-2]:this.p.ranges[0].from,d=this.reducePos-h;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=d));let m=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-m;if(r<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,y,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let y=this.stack[u-3];this.state=s.getGoto(y,r,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,c=this.buffer.length;if(c==0&&o.parent&&(c=o.bufferBase-o.parent.bufferBase,o=o.parent),c>0&&o.buffer[c-4]==0&&o.buffer[c-1]>-1){if(n==i)return;if(o.buffer[c-2]>=n){o.buffer[c-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let c=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){c=!0;break}if(c)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let c=o.stateFlag(s,1);!c&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,c?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,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,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new ap(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new ioe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((c,u)=>u&1&&c==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let c=(o>>19)-s;if(c>1){let u=o&65535,h=this.stack.length-c*3;if(h>=0&&e.getGoto(this.stack[h],u,!1)>=0)return c<<19|65536|u}}else{let c=i(o,s+1);if(c!=null)return c}})};return i(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 n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}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 n=new b4(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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()}}class b4{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class ioe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class op{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new op(e,n,n-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 op(this.stack,this.pos,this.index)}}function td(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),c=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,c=!0),s+=u,c)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class pd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const x4=new pd;class roe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=x4,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,c=this.range;for(;c.to<=i;)c=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>c.to&&(this.chunk2=this.chunk2.slice(0,c.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=x4,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class cl{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;soe(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}cl.prototype.contextual=cl.prototype.fallback=cl.prototype.extend=!1;cl.prototype.fallback=cl.prototype.extend=!1;class Kp{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function soe(t,e,n,i,r,s){let o=0,c=1<<i,{dialect:u}=n.p.parser;e:for(;(c&t[o])!=0;){let h=t[o+1];for(let y=o+3;y<h;y+=2)if((t[y+1]&c)>0){let x=t[y];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||aoe(x,e.token.value,r,s))){e.acceptToken(x);break}}let d=e.next,m=0,g=t[o+2];if(e.next<0&&g>m&&t[h+g*3-3]==65535){o=t[h+g*3-1];continue e}for(;m<g;){let y=m+g>>1,x=h+y+(y<<1),w=t[x],S=t[x+1]||65536;if(d<w)g=y;else if(d>=S)m=y+1;else{o=t[x+2],e.advance();continue e}}break}}function w4(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function aoe(t,e,n,i){let r=w4(n,i,e);return r<0||w4(n,i,t)<r}const si=typeof process<"u"&&v4&&/\bparse\b/.test(v4.LOG);let Rw=null;function S4(t,e,n){let i=t.cursor(Nt.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class ooe{constructor(e,n){this.fragments=e,this.nodeSet=n,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?S4(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?S4(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof It){if(o==e){if(o<this.safeFrom)return null;let c=o+s.length;if(c<=this.safeTo){let u=s.prop(Fe.lookAhead);if(!u||c+u<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class loe{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new pd)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,u=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let d=s[h],m=this.tokens[h];if(!(i&&!d.fallback)&&((d.contextual||m.start!=e.pos||m.mask!=o||m.context!=c)&&(this.updateCachedToken(m,d,e),m.mask=o,m.context=c),m.lookAhead>m.end+25&&(u=Math.max(m.lookAhead,u)),m.value!=0)){let g=n;if(m.extended>-1&&(n=this.addActions(e,m.extended,m.end,n)),n=this.addActions(e,m.value,m.end,n),!d.extend&&(i=m,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new pd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new pd,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let c=s.specializers[o](this.stream.read(e.start,e.end),i);if(c>=0&&i.p.parser.dialect.allows(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:c}=o;for(let u=0;u<2;u++)for(let h=o.stateSlot(s,u?2:1);;h+=3){if(c[h]==65535)if(c[h+1]==1)h=Vr(c,h+2);else{r==0&&c[h+1]==2&&(r=this.putAction(Vr(c,h+2),n,i,r));break}c[h]==n&&(r=this.putAction(Vr(c,h+1),n,i,r))}return r}}class coe{constructor(e,n,i,r){this.parser=e,this.input=n,this.ranges=r,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 roe(n,r),this.tokens=new loe(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ap.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new ooe(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let c=e[o];for(;;){if(this.tokens.mainToken=null,c.pos>n)i.push(c);else{if(this.advanceStack(c,i,e))continue;{r||(r=[],s=[]),r.push(c);let u=this.tokens.getMainToken(c);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&hoe(r);if(o)return si&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw si&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return si&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((c,u)=>u.score-c.score);i.length>o;)i.pop();i.some(c=>c.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let c=i[o];for(let u=o+1;u<i.length;u++){let h=i[u];if(c.sameState(h)||c.buffer.length>500&&h.buffer.length>500)if((c.score-h.score||c.buffer.length-h.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,c)=>c.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].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,n,i){let r=e.pos,{parser:s}=this,o=si?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,d=h?e.curContext.hash:0;for(let m=this.fragments.nodeAt(r);m;){let g=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(g>-1&&m.length&&(!h||(m.prop(Fe.contextHash)||0)==d))return e.useNode(m,g),si&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof It)||m.children.length==0||m.positions[0]>0)break;let y=m.children[0];if(y instanceof It&&m.positions[0]==0)m=y;else break}}let c=s.stateSlot(e.state,4);if(c>0)return e.reduce(c),si&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let h=0;h<u.length;){let d=u[h++],m=u[h++],g=u[h++],y=h==u.length||!i,x=y?e:e.split(),w=this.tokens.mainToken;if(x.apply(d,m,w?w.start:x.pos,g),si&&console.log(o+this.stackID(x)+` (via ${(d&65536)==0?"shift":`reduce of ${s.getName(d&65535)}`} for ${s.getName(m)} @ ${r}${x==e?"":", split"})`),y)return!0;x.pos>r?n.push(x):i.push(x)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return C4(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o],u=n[o<<1],h=n[(o<<1)+1],d=si?this.stackID(c)+" -> ":"";if(c.deadEnd&&(s||(s=!0,c.restart(),si&&console.log(d+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let m=c.split(),g=d;for(let y=0;y<10&&m.forceReduce()&&(si&&console.log(g+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));y++)si&&(g=this.stackID(m)+" -> ");for(let y of c.recoverByInsert(u))si&&console.log(d+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>c.pos?(h==c.pos&&(h++,u=0),c.recoverByDelete(u,h),si&&console.log(d+this.stackID(c)+` (via recover-delete ${this.parser.getName(u)})`),C4(c,i)):(!r||r.score<m.score)&&(r=m)}return r}stackToTree(e){return e.close(),It.build({buffer:op.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 n=(Rw||(Rw=new WeakMap)).get(e);return n||Rw.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function C4(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class uoe{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Nw=t=>t;class foe{constructor(e){this.start=e.start,this.shift=e.shift||Nw,this.reduce=e.reduce||Nw,this.reuse=e.reuse||Nw,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class lp extends oq{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;c<e.repeatNodeCount;c++)n.push("");let i=Object.keys(e.topRules).map(c=>e.topRules[c][1]),r=[];for(let c=0;c<n.length;c++)r.push([]);function s(c,u,h){r[c].push([u,u.deserialize(String(h))])}if(e.nodeProps)for(let c of e.nodeProps){let u=c[0];typeof u=="string"&&(u=Fe[u]);for(let h=1;h<c.length;){let d=c[h++];if(d>=0)s(d,u,c[h++]);else{let m=c[h+-d];for(let g=-d;g>0;g--)s(c[h++],u,m);h++}}}this.nodeSet=new SC(n.map((c,u)=>Xn.define({name:u>=this.minRepeatTerm?void 0:c,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iq;let o=td(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;c<this.specializerSpecs.length;c++)this.specialized[c]=this.specializerSpecs[c].term;this.specializers=this.specializerSpecs.map(k4),this.states=td(e.states,Uint32Array),this.data=td(e.stateData),this.goto=td(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(c=>typeof c=="number"?new cl(o,c):c),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,n,i){let r=new coe(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],c=o&1,u=r[s++];if(c&&i)return u;for(let h=s+(o>>1);s<h;s++)if(r[s]==e)return u;if(c)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Vr(i,s+2)];else{if(i[s+1]==2)return Vr(i,s+2);break}if(o==n||o==0)return Vr(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vr(this.data,s+2);else break;r=n(Vr(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Vr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(lp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(c=>c.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=k4(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}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 n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],c;(c=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[c]=1;return new uoe(e,i,r)}static deserialize(e){return new lp(e)}}function Vr(t,e){return t[e]|t[e+1]<<16}function hoe(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function k4(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}const Uo=63,A4=64,doe=1,poe=2,Mj=3,moe=4,Rj=5,goe=6,yoe=7,Nj=65,voe=66,boe=8,xoe=9,woe=10,Soe=11,Coe=12,Dj=13,koe=19,Aoe=20,_oe=29,Ooe=33,Eoe=34,Toe=47,Moe=0,HC=1,i2=2,Tu=3,r2=4;class Ta{constructor(e,n,i){this.parent=e,this.depth=n,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+n+(n<<4)+i}}Ta.top=new Ta(null,-1,Moe);function eu(t,e){for(let n=0,i=e-t.pos-1;;i--,n++){let r=t.peek(i);if(es(r)||r==-1)return n}}function s2(t){return t==32||t==9}function es(t){return t==10||t==13}function Lj(t){return s2(t)||es(t)}function za(t){return t<0||Lj(t)}const Roe=new foe({start:Ta.top,reduce(t,e){return t.type==Tu&&(e==Aoe||e==Eoe)?t.parent:t},shift(t,e,n,i){if(e==Mj)return new Ta(t,eu(i,i.pos),HC);if(e==Nj||e==Rj)return new Ta(t,eu(i,i.pos),i2);if(e==Uo)return t.parent;if(e==koe||e==Ooe)return new Ta(t,0,Tu);if(e==Dj&&t.type==r2)return t.parent;if(e==Toe){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Ta(t,t.depth+ +r[0],r2)}return t},hash(t){return t.hash}});function xl(t,e,n=0){return t.peek(n)==e&&t.peek(n+1)==e&&t.peek(n+2)==e&&za(t.peek(n+3))}const Noe=new Kp((t,e)=>{if(t.next==-1&&e.canShift(A4))return t.acceptToken(A4);let n=t.peek(-1);if((es(n)||n<0)&&e.context.type!=Tu){if(xl(t,45))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(doe,3);if(xl(t,46))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(poe,3);let i=0;for(;t.next==32;)i++,t.advance();(i<e.context.depth||i==e.context.depth&&e.context.type==HC&&(t.next!=45||!za(t.peek(1))))&&t.next!=-1&&!es(t.next)&&t.next!=35&&t.acceptToken(Uo,-i)}},{contextual:!0}),Doe=new Kp((t,e)=>{if(e.context.type==Tu){t.next==63&&(t.advance(),za(t.next)&&t.acceptToken(yoe));return}if(t.next==45)t.advance(),za(t.next)&&t.acceptToken(e.context.type==HC&&e.context.depth==eu(t,t.pos-1)?moe:Mj);else if(t.next==63)t.advance(),za(t.next)&&t.acceptToken(e.context.type==i2&&e.context.depth==eu(t,t.pos-1)?goe:Rj);else{let n=t.pos;for(;;)if(s2(t.next)){if(t.pos==n)return;t.advance()}else if(t.next==33)zj(t);else if(t.next==38)a2(t);else if(t.next==42){a2(t);break}else if(t.next==39||t.next==34){if(UC(t,!0))break;return}else if(t.next==91||t.next==123){if(!zoe(t))return;break}else{Bj(t,!0,!1,0);break}for(;s2(t.next);)t.advance();if(t.next==58){if(t.pos==n&&e.canShift(_oe))return;let i=t.peek(1);za(i)&&t.acceptTokenTo(e.context.type==i2&&e.context.depth==eu(t,n)?voe:Nj,n)}}},{contextual:!0});function Loe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function _4(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function O4(t,e){return t.next==37?(t.advance(),_4(t.next)&&t.advance(),_4(t.next)&&t.advance(),!0):Loe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function zj(t){if(t.advance(),t.next==60){for(t.advance();;)if(!O4(t,!0)){t.next==62&&t.advance();break}}else for(;O4(t,!1););}function a2(t){for(t.advance();!za(t.next)&&cp(t.next)!="f";)t.advance()}function UC(t,e){let n=t.next,i=!1,r=t.pos;for(t.advance();;){let s=t.next;if(s<0)break;if(t.advance(),s==n)if(s==39)if(t.next==39)t.advance();else break;else break;else if(s==92&&n==34)t.next>=0&&t.advance();else if(es(s)){if(e)return!1;i=!0}else if(e&&t.pos>=r+1024)return!1}return!i}function zoe(t){for(let e=[],n=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!UC(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>n||es(t.next))return!1;t.advance()}}const Boe="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function cp(t){return t<33?"u":t>125?"s":Boe[t-33]}function Dw(t,e){let n=cp(t);return n!="u"&&!(e&&n=="f")}function Bj(t,e,n,i){if(cp(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&Dw(t.peek(1),n))t.advance();else return!1;let r=t.pos;for(;;){let s=t.next,o=0,c=i+1;for(;Lj(s);){if(es(s)){if(e)return!1;c=0}else c++;s=t.peek(++o)}if(!(s>=0&&(s==58?Dw(t.peek(o+1),n):s==35?t.peek(o-1)!=32:Dw(s,n)))||!n&&c<=i||c==0&&!n&&(xl(t,45,o)||xl(t,46,o)))break;if(e&&cp(s)=="f")return!1;for(let h=o;h>=0;h--)t.advance();if(e&&t.pos>r+1024)return!1}return!0}const qoe=new Kp((t,e)=>{if(t.next==33)zj(t),t.acceptToken(Coe);else if(t.next==38||t.next==42){let n=t.next==38?woe:Soe;a2(t),t.acceptToken(n)}else t.next==39||t.next==34?(UC(t,!1),t.acceptToken(xoe)):Bj(t,!1,e.context.type==Tu,e.context.depth)&&t.acceptToken(boe)}),joe=new Kp((t,e)=>{let n=e.context.type==r2?e.context.depth:-1,i=t.pos;e:for(;;){let r=0,s=t.next;for(;s==32;)s=t.peek(++r);if(!r&&(xl(t,45,r)||xl(t,46,r))||!es(s)&&(n<0&&(n=Math.max(e.context.depth+1,r)),r<n))break;for(;;){if(t.next<0)break e;let o=es(t.next);if(t.advance(),o)continue e;i=t.pos}}t.acceptTokenTo(Dj,i)}),Ioe=lq({DirectiveName:le.keyword,DirectiveContent:le.attributeValue,"DirectiveEnd DocEnd":le.meta,QuotedLiteral:le.string,BlockLiteralHeader:le.special(le.string),BlockLiteralContent:le.content,Literal:le.content,"Key/Literal Key/QuotedLiteral":le.definition(le.propertyName),"Anchor Alias":le.labelName,Tag:le.typeName,Comment:le.lineComment,": , -":le.separator,"?":le.punctuation,"[ ]":le.squareBracket,"{ }":le.brace}),Poe=lp.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Roe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Ioe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Noe,Doe,qoe,joe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Hoe=Gd.define({name:"yaml",parser:Poe.configure({props:[hq.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let n=t.column(e.from,1);if(n==t.lineIndent(e.from,1))return n;if(e.to>t.pos)return null}}return null},FlowMapping:L5({closing:"}"}),FlowSequence:L5({closing:"]"})}),mq.add({"FlowMapping FlowSequence":xie,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Uoe(){return new cie(Hoe)}const Voe=()=>{const{error:t,isCliMode:e,yamlInput:n,setYamlInput:i,parseAndSetSchema:r,isAutoSaveEnabled:s,setIsAutoSaveEnabled:o,savingStatus:c,saveSchema:u,lastUpdateSource:h,theme:d}=ci(),[m,g]=j.useState(n),y=j.useRef(null),x=j.useRef(null),w=j.useRef(!0);j.useEffect(()=>{if(!x.current?.view)return;const E=x.current.view,T=E.state.doc.toString();if(w.current&&n){E.dispatch({changes:{from:0,to:T.length,insert:n},annotations:Qt.addToHistory.of(!1)}),g(n),w.current=!1;return}h==="visual"&&T!==n&&(E.dispatch({changes:{from:0,to:T.length,insert:n},userEvent:"visual-edit"}),g(n))},[n,h]);const S=j.useCallback(E=>{g(E),!(!E||E.trim()==="")&&(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{i(E),r(E)},300))},[i,r]),C=async()=>{r(m),e&&await u(!0)},A=()=>{x.current?.view&&MC(x.current.view)},O=()=>{x.current?.view&&Kd(x.current.view)};return k.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full",children:[k.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?k.jsxs("div",{className:"flex items-center gap-4",children:[k.jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",children:[k.jsx("div",{className:`relative w-7 h-4 rounded-full transition-colors ${s?"bg-blue-600":"bg-slate-300 dark:bg-slate-700"}`,onClick:()=>o(!s),children:k.jsx("div",{className:`absolute top-0.5 left-0.5 w-3 h-3 bg-white rounded-full transition-transform ${s?"translate-x-3":"translate-x-0"}`})}),k.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${d==="dark"?"text-slate-500 group-hover:text-slate-400":"text-slate-400 group-hover:text-slate-600"}`,children:"Auto-save"})]}),k.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[c==="saving"&&k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[k.jsx(xK,{size:10,className:"animate-spin"}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),c==="saved"&&k.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[k.jsx(nK,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),c==="error"&&k.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[k.jsx(K1,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):k.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[k.jsx(K1,{size:12,className:"text-blue-400"}),k.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsxs("div",{className:`flex rounded-lg p-0.5 border ${d==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[k.jsx("button",{onClick:A,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:k.jsx(Y8,{size:14})}),k.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${d==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),k.jsx("button",{onClick:O,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:k.jsx($8,{size:14})})]}),k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[k.jsx(mK,{size:12}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),k.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${d==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[k.jsx(Tj,{ref:x,value:m,height:"100%",theme:d==="dark"?Ej:"light",extensions:[Uoe()],onChange:S,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&m===n&&k.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[k.jsx(K1,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),k.jsx("span",{children:t})]})]}),k.jsxs("div",{className:"flex justify-between items-center pt-1 shrink-0",children:[k.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?s?"Changes save automatically":"Click save to update file":"Changes reset on reload"}),k.jsxs("button",{onClick:C,disabled:c==="saving",className:`flex items-center gap-2 px-4 py-2 rounded-md font-medium text-sm transition-all shadow-lg shrink-0 ${e?s?"bg-slate-300 dark:bg-slate-700 text-slate-500 dark:text-slate-400 cursor-not-allowed opacity-50":"bg-blue-600 hover:bg-blue-700 text-white":"bg-emerald-600 hover:bg-emerald-700 text-white"}`,children:[e?k.jsx(UK,{size:16}):k.jsx(BK,{size:16}),e?"Save & Update":"Apply Changes"]})]})]})},Foe=()=>{const{schema:t,setSelectedTableId:e,setFocusNodeId:n,theme:i}=ci(),[r,s]=j.useState(""),[o,c]=j.useState(new Set),u=m=>{const g=new Set(o);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{e(m),n(m)},d=j.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const S=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&S&&(m[S.id].push(w),g.add(w.id))});const y=(t.domains||[]).filter(w=>{const S=m[w.id].length>0,C=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return S||C&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(C=>C.tables.includes(w.id)));return{domains:y,unassigned:x}},[t,r]);return t?k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 pt-2",children:[k.jsxs("div",{className:"relative mb-4 shrink-0",children:[k.jsx(FK,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),k.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),placeholder:"Search entities...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),k.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=o.has(m.id);return k.jsxs("section",{className:"flex flex-col",children:[k.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u(m.id),children:[k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.tables.length})]}),k.jsx("button",{onClick:y=>{y.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",title:"Focus on Domain",children:k.jsx(W1,{size:12})})]}),!g&&k.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(y=>k.jsxs("button",{onClick:()=>h(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:y.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},y.id)),m.tables.length===0&&k.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables in this domain"})]})]},m.id)}),d.unassigned.length>0&&k.jsxs("section",{className:"flex flex-col",children:[k.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u("unassigned"),children:k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx(F8,{size:12,className:"text-slate-500 shrink-0"}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:d.unassigned.length})]})}),!o.has("unassigned")&&k.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>k.jsxs("button",{onClick:()=>h(m.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:m.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]}),d.domains.length===0&&d.unassigned.length===0&&k.jsx("div",{className:"text-center py-10",children:k.jsxs("p",{className:"text-sm text-slate-500 italic",children:['No entities found for "',r,'"']})})]})]}):null},$oe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,theme:n}=ci();return k.jsx("button",{onClick:()=>e(!t),className:`absolute -right-3.5 top-1/2 -translate-y-1/2 z-[60] flex h-7 w-7 items-center justify-center rounded-full border transition-all shadow-xl ${n==="dark"?"border-slate-700 bg-slate-900 text-slate-400 hover:text-white hover:bg-slate-800":"border-slate-200 bg-white text-slate-500 hover:text-blue-600 hover:bg-slate-50 shadow-slate-200/50"}`,"aria-label":t?"Collapse sidebar":"Expand sidebar",children:t?k.jsx(ZW,{size:16}):k.jsx(nS,{size:16})})},Goe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:n,isSidebarOpen:i,fetchAvailableFiles:r,theme:s}=ci(),[o,c]=j.useState(!1);if(!i||t.length<=0)return null;const u=async()=>{c(!0),await r(),setTimeout(()=>c(!1),500)},h=e||t[0]?.slug;return k.jsxs("div",{className:"px-4 mb-4",children:[k.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[k.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"}),k.jsx("button",{onClick:u,className:`transition-all p-0.5 rounded ${o?"animate-spin text-blue-400":"text-slate-500 hover:text-blue-400"} ${s==="dark"?"hover:bg-slate-800":"hover:bg-slate-100"}`,title:"Refresh model list",children:k.jsx(PK,{size:12})})]}),k.jsxs("div",{className:"relative group",children:[k.jsx("select",{value:h,onChange:d=>n(d.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${s==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(d=>k.jsx("option",{value:d.slug,className:s==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:d.name},d.slug))}),k.jsx(Go,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),k.jsx(tS,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${s==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Yoe=""+new URL("../favicon.svg",import.meta.url).href,Qoe=()=>{const{isSidebarOpen:t,activeTab:e,setActiveTab:n,isCliMode:i,theme:r,toggleTheme:s}=ci();return k.jsxs("div",{className:`relative h-full flex flex-col border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[400px]":"w-[50px]"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[k.jsx($oe,{}),k.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${!t&&"hidden"} ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("img",{src:Yoe,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),k.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"})]}),i&&k.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase",children:"Live"})]}),k.jsx("div",{className:"mt-4",children:t&&k.jsx(Goe,{})}),k.jsxs(RJ,{value:e,onValueChange:o=>n(o),className:`flex-1 flex flex-col overflow-hidden ${!t&&"items-center py-4"}`,children:[k.jsx("div",{className:`px-4 pt-4 ${!t&&"px-0"}`,children:k.jsxs(NB,{className:`w-full p-1 border ${r==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"} ${!t&&"flex-col h-auto w-10 gap-2 p-0 bg-transparent border-none"}`,children:[k.jsxs(oS,{value:"editor",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Editor",children:[k.jsx(LK,{size:14}),t&&k.jsx("span",{children:"Editor"})]}),k.jsxs(oS,{value:"entities",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Entities",children:[k.jsx(vK,{size:14}),t&&k.jsx("span",{children:"Entities"})]})]})}),t&&k.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[k.jsx(lS,{value:"editor",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Voe,{})}),k.jsx(lS,{value:"entities",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Foe,{})})]})]}),t&&k.jsxs("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:[k.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.0.7"}),k.jsx("button",{onClick:s,className:`p-1.5 rounded-lg transition-all ${r==="dark"?"text-slate-400 hover:bg-slate-800 hover:text-yellow-400":"text-slate-500 hover:bg-slate-200 hover:text-blue-600"}`,title:`Switch to ${r==="dark"?"Light":"Dark"} Mode`,children:r==="dark"?k.jsx(GK,{size:14}):k.jsx(AK,{size:14})})]})]})},Xoe=()=>{const{addTable:t,addDomain:e,getSelectedTable:n,getSelectedDomain:i,getSelectedRelationship:r,removeNode:s,removeEdge:o,showER:c,showLineage:u,setShowER:h,setShowLineage:d,setSelectedTableId:m,setSelectedEdgeId:g,calculateAutoLayout:y,theme:x}=ci(),{screenToFlowPosition:w}=Du(),[S,C]=j.useState(!1),A=c&&u,O=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});e(P.x-300,P.y-200)},E=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});t(P.x-160,P.y-125)},T=n(),M=i(),R=r(),z=T||M||R,q=()=>{T?s(T.id):M?s(M.id):R&&o(R.relationship.from.table,R.relationship.to.table)},U=()=>{m(null),g(null)};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"absolute top-4 left-4 z-10 flex flex-col gap-2",children:[k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl overflow-hidden w-14 transition-colors ${x==="dark"?"bg-slate-900/85 backdrop-blur-md border-slate-700":"bg-white/90 backdrop-blur-md border-slate-200"}`,children:[k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(lK,{size:12}),k.jsx("span",{children:"View"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsx("button",{onClick:()=>h(!c),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${c?"bg-emerald-500/20 text-emerald-500 border border-emerald-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:c?"Hide ER Relationships":"Show ER Relationships (Disables editing if Lineage is also ON)",children:k.jsx(RK,{size:20})}),k.jsx("button",{onClick:()=>d(!u),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${u?"bg-blue-500/20 text-blue-500 border border-blue-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:u?"Hide Data Lineage":"Show Data Lineage (Disables editing if ER is also ON)",children:k.jsx(g3,{size:20})})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(rS,{size:12}),k.jsx("span",{children:"Add"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsxs("button",{onClick:O,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-50"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Domain",children:[k.jsx(v3,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]}),k.jsxs("button",{onClick:E,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-emerald-400 hover:bg-slate-800":"text-slate-400 hover:text-emerald-600 hover:bg-slate-100"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Table",children:[k.jsx(fK,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(y3,{size:12}),k.jsx("span",{children:"Format"})]}),k.jsx("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:k.jsx("button",{onClick:()=>y(),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group ${x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-100"}`,title:"Auto-format Layout (Relation-driven flow)",children:k.jsx(y3,{size:20})})})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsx("div",{className:"flex flex-col items-center py-3",children:k.jsx("button",{onClick:()=>C(!S),className:`flex items-center justify-center w-10 h-10 rounded-xl transition-all ${S?x==="dark"?"bg-blue-600 text-white":"bg-blue-600 text-white shadow-md shadow-blue-500/20":x==="dark"?"text-slate-500 hover:bg-slate-800 hover:text-slate-300":"text-slate-400 hover:bg-slate-100 hover:text-slate-600"}`,title:"Keyboard Shortcuts & Help",children:k.jsx(F8,{size:20})})})]}),S&&k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl p-5 w-64 animate-in zoom-in-95 fade-in duration-200 origin-top-left ${x==="dark"?"bg-slate-900/95 backdrop-blur-xl border-slate-700":"bg-white/95 backdrop-blur-xl border-slate-200"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 mb-4 border-b pb-3 ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsx(sK,{size:16,className:"text-blue-500"}),k.jsx("h4",{className:`text-xs font-bold uppercase tracking-widest ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:"Shortcuts"})]}),k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Y8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Undo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Z"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx($8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Redo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Y"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Md,{size:14}),k.jsx("span",{className:"text-xs font-medium text-red-500/80",children:"Delete"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300 text-red-400/80":"bg-slate-50 border-slate-200 text-red-600/80"}`,children:"Del"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Yo,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Clear Focus"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Esc"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(TK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Pan Canvas"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Arrow Keys"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(OK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Multi-select"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Shift + Drag"})]})]}),k.jsx("div",{className:`mt-5 pt-3 border-t text-[10px] text-slate-400 italic leading-relaxed ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:"* Edits are saved to local YAML files in real-time if Auto-save is enabled."})]})]}),z&&k.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${x==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${x==="dark"?"border-slate-700":"border-slate-100"}`,children:[T&&k.jsx(Go,{size:16,className:"text-emerald-500"}),M&&k.jsx(v3,{size:16,className:"text-blue-500"}),R&&(R.relationship.type==="lineage"?k.jsx(g3,{size:16,className:"text-blue-400"}):k.jsx(G8,{size:16,className:"text-amber-500"})),k.jsxs("div",{className:"flex flex-col leading-tight",children:[k.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:["Selected ",T?"Table":M?"Domain":R?.relationship.type==="lineage"?"Lineage":"Relation"]}),k.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:T?T.name:M?M.name:R?`${R.relationship.from.table} → ${R.relationship.to.table}`:""})]})]}),k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsx("button",{onClick:q,className:"flex items-center justify-center w-8 h-8 hover:bg-red-500/20 text-slate-400 hover:text-red-500 rounded-lg transition-all group",title:"Delete Selected (Del)",children:k.jsx(Md,{size:16})}),k.jsx("button",{onClick:U,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection",children:k.jsx(Yo,{size:16})})]})]})]})},Woe=t=>{if(!t)return["",""];const n=t.toLowerCase().split("-to-");return n.length!==2?["",""]:n.map(i=>i.includes("one")?"1":i.includes("many")?"M":"")},E4=(t,e,n,i=45)=>{switch(n){case Te.Top:return{x:t,y:e-i};case Te.Bottom:return{x:t,y:e+i};case Te.Left:return{x:t-i,y:e};case Te.Right:return{x:t+i,y:e};default:return{x:t,y:e}}};function Koe({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r,targetPosition:s,style:o={},markerEnd:c,markerStart:u,label:h,data:d}){const[m]=Sd({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s}),{theme:g}=ci(),y=d?.isDirectlySelected,x=d?.isConnectedToSelectedTable,w=y||x,S=d?.label||h||"",[C,A]=Woe(S),O=E4(t,e,r),E=E4(n,i,s),T=({x:M,y:R,symbol:z})=>{if(!z)return null;const q=z==="1",U=`
|
|
51
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ose(this):new kse(this)}getCursor(e,n=0,i){let r=e.doc?e:Je.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Ho(this,r,n,i):Po(this,r,n,i)}}class uj{constructor(e){this.spec=e}}function Sse(t,e,n){return(i,r,s,o)=>{if(n&&!n(i,r,s,o))return!1;let c=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return t(c,e,i,r)}}function Po(t,e,n,i){let r;return t.wholeWord&&(r=Cse(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(r=Sse(t.test,e,r)),new bl(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Cse(t,e){return(n,i,r,s)=>((s>n||s+r.length<i)&&(s=Math.max(0,n-2),r=t.sliceString(s,Math.min(t.length,i+2))),(e(ep(r,n-s))!=At.Word||e(tp(r,n-s))!=At.Word)&&(e(tp(r,i-s))!=At.Word||e(ep(r,i-s))!=At.Word))}class kse extends uj{constructor(e){super(e)}nextMatch(e,n,i){let r=Po(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Po(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==i?null:r.value}prevMatchInRange(e,n,i){for(let r=i;;){let s=Math.max(n,r-1e4-this.spec.unquoted.length),o=Po(this.spec,e,s,r),c=null;for(;!o.nextOverlapping().done;)c=o.value;if(c)return c;if(s==n)return null;r-=1e4}}prevMatch(e,n,i){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let i=Po(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Po(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Ase(t,e,n){return(i,r,s)=>(!n||n(i,r,s))&&t(s[0],e,i,r)}function Ho(t,e,n,i){let r;return t.wholeWord&&(r=_se(e.charCategorizer(e.selection.main.head))),t.test&&(r=Ase(t.test,e,r)),new oj(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},n,i)}function ep(t,e){return t.slice(sn(t,e,!1),e)}function tp(t,e){return t.slice(e,sn(t,e))}function _se(t){return(e,n,i)=>!i[0].length||(t(ep(i.input,i.index))!=At.Word||t(tp(i.input,i.index))!=At.Word)&&(t(tp(i.input,i.index+i[0].length))!=At.Word||t(ep(i.input,i.index+i[0].length))!=At.Word)}class Ose extends uj{nextMatch(e,n,i){let r=Ho(this.spec,e,i,e.doc.length).next();return r.done&&(r=Ho(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),o=Ho(this.spec,e,s,i),c=null;for(;!o.next().done;)c=o.value;if(c&&(s==n||c.from>s+10))return c;if(s==n)return null}}prevMatch(e,n,i){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+i.slice(r)}return n})}matchAll(e,n){let i=Ho(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Ho(this.spec,e,Math.max(0,n-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const ku=je.define(),DC=je.define(),Vs=_n.define({create(t){return new Aw(t2(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ku)?t=new Aw(n.value.create(),t.panel):n.is(DC)&&(t=new Aw(t.query,n.value?LC:null));return t},provide:t=>xu.from(t,e=>e.panel)});class Aw{constructor(e,n){this.query=e,this.panel=n}}const Ese=Le.mark({class:"cm-searchMatch"}),Tse=Le.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Mse=zt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Vs))}update(t){let e=t.state.field(Vs);(e!=t.startState.field(Vs)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Le.none;let{view:n}=this,i=new Kr;for(let r=0,s=n.visibleRanges,o=s.length;r<o;r++){let{from:c,to:u}=s[r];for(;r<o-1&&u>s[r+1].from-500;)u=s[++r].to;t.highlight(n.state,c,u,(h,d)=>{let m=n.state.selection.ranges.some(g=>g.from==h&&g.to==d);i.add(h,d,m?Tse:Ese)})}return i.finish()}},{decorations:t=>t.decorations});function Yu(t){return e=>{let n=e.state.field(Vs,!1);return n&&n.query.spec.valid?t(e,n):dj(e)}}const np=Yu((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=de.single(i.from,i.to),s=t.state.facet(Tl);return t.dispatch({selection:r,effects:[zC(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),hj(t),!0}),ip=Yu((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=de.single(r.from,r.to),o=t.state.facet(Tl);return t.dispatch({selection:s,effects:[zC(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),hj(t),!0}),Rse=Yu((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:de.create(n.map(i=>de.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Nse=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let c=new bl(t.doc,t.sliceDoc(i,r));!c.next().done;){if(s.length>1e3)return!1;c.value.from==i&&(o=s.length),s.push(de.range(c.value.from,c.value.to))}return e(t.update({selection:de.create(s,o),userEvent:"select.search.matches"})),!0},K5=Yu((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,c=[],u,h,d=[];o.from==i&&o.to==r&&(h=n.toText(e.getReplacement(o)),c.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(n,o.from,o.to),d.push(Se.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let m=t.state.changes(c);return o&&(u=de.single(o.from,o.to).map(m),d.push(zC(t,o)),d.push(n.facet(Tl).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:d,userEvent:"input.replace"}),!0}),Dse=Yu((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:Se.announce.of(i),userEvent:"input.replace.all"}),!0});function LC(t){return t.state.facet(Tl).createPanel(t)}function t2(t,e){var n,i,r,s,o;let c=t.selection.main,u=c.empty||c.to>c.from+100?"":t.sliceDoc(c.from,c.to);if(e&&!u)return e;let h=t.facet(Tl);return new cj({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function fj(t){let e=wC(t,LC);return e&&e.dom.querySelector("[main-field]")}function hj(t){let e=fj(t);e&&e==t.root.activeElement&&e.select()}const dj=t=>{let e=t.state.field(Vs,!1);if(e&&e.panel){let n=fj(t);if(n&&n!=t.root.activeElement){let i=t2(t.state,e.query.spec);i.valid&&t.dispatch({effects:ku.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[DC.of(!0),e?ku.of(t2(t.state,e.query.spec)):je.appendConfig.of(qse)]});return!0},pj=t=>{let e=t.state.field(Vs,!1);if(!e||!e.panel)return!1;let n=wC(t,LC);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:DC.of(!1)}),!0},Lse=[{key:"Mod-f",run:dj,scope:"editor search-panel"},{key:"F3",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Nse},{key:"Mod-Alt-g",run:use},{key:"Mod-d",run:wse,preventDefault:!0}];class zse{constructor(e){this.view=e;let n=this.query=e.state.field(Vs).query.spec;this.commit=this.commit.bind(this),this.searchField=dt("input",{value:n.search,placeholder:ri(e,"Find"),"aria-label":ri(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=dt("input",{value:n.replace,placeholder:ri(e,"Replace"),"aria-label":ri(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=dt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=dt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=dt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,o){return dt("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=dt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>np(e),[ri(e,"next")]),i("prev",()=>ip(e),[ri(e,"previous")]),i("select",()=>Rse(e),[ri(e,"all")]),dt("label",null,[this.caseField,ri(e,"match case")]),dt("label",null,[this.reField,ri(e,"regexp")]),dt("label",null,[this.wordField,ri(e,"by word")]),...e.state.readOnly?[]:[dt("br"),this.replaceField,i("replace",()=>K5(e),[ri(e,"replace")]),i("replaceAll",()=>Dse(e),[ri(e,"replace all")])],dt("button",{name:"close",onclick:()=>pj(e),"aria-label":ri(e,"close"),type:"button"},["×"])])}commit(){let e=new cj({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ku.of(e)}))}keydown(e){Ite(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ip:np)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),K5(this.view))}update(e){for(let n of e.transactions)for(let i of n.effects)i.is(ku)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Tl).top}}function ri(t,e){return t.state.phrase(e)}const Kh=30,Zh=/[\s\.,:;?!]/;function zC(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-Kh),o=Math.min(r,n+Kh),c=t.state.sliceDoc(s,o);if(s!=i.from){for(let u=0;u<Kh;u++)if(!Zh.test(c[u+1])&&Zh.test(c[u])){c=c.slice(u);break}}if(o!=r){for(let u=c.length-1;u>c.length-Kh;u--)if(!Zh.test(c[u-1])&&Zh.test(c[u])){c=c.slice(0,u);break}}return Se.announce.of(`${t.state.phrase("current match")}. ${c} ${t.state.phrase("on line")} ${i.number}.`)}const Bse=Se.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),qse=[Vs,Za.low(Mse),Bse];class mj{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Cn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(gj(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Z5(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jse(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=Z5(e)+Z5(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Ise(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:jse(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class J5{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function Ia(t){return t.selection.main.from}function gj(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const yj=dr.define();function Pse(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(c=>{if(c!=r&&n!=i&&t.sliceDoc(c.from+s,c.from+o)!=t.sliceDoc(n,i))return{range:c};let u=t.toText(e);return{changes:{from:c.from+s,to:i==r.from?c.to:c.from+o,insert:u},range:de.cursor(c.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const e4=new WeakMap;function Hse(t){if(!Array.isArray(t))return t;let e=e4.get(t);return e||e4.set(t,e=Ise(t)),e}const rp=je.define(),Au=je.define();class Use{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=In(e,n),r=ir(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(In(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let A=In(e,0),O=ir(A),E=O==e.length?0:-100;if(A!=n[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,O])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=n.length,h=0;if(c<0){for(let A=0,O=Math.min(e.length,200);A<O&&h<u;){let E=In(e,A);(E==n[h]||E==i[h])&&(r[h++]=A),A+=ir(E)}if(h<u)return null}let d=0,m=0,g=!1,y=0,x=-1,w=-1,S=/[a-z]/.test(e),C=!0;for(let A=0,O=Math.min(e.length,200),E=0;A<O&&m<u;){let T=In(e,A);c<0&&(d<u&&T==n[d]&&(s[d++]=A),y<u&&(T==n[y]||T==i[y]?(y==0&&(x=A),w=A+1,y++):y=0));let M,R=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(M=iC(T))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||R==1&&S||E==0&&R!=0)&&(n[m]==T||i[m]==T&&(g=!0)?o[m++]=A:o.length&&(C=!1)),E=R,A+=ir(T)}return m==u&&o[0]==0&&C?this.result(-100+(g?-200:0),o,e):y==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):y==u?this.ret(-900-e.length,[x,w]):m==u?this.result(-100+(g?-200:0)+-700+(C?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let c=o+(this.astral?ir(In(i,o)):1);s&&r[s-1]==o?r[s-1]=c:(r[s++]=o,r[s++]=c)}return this.ret(e-i.length,r)}}class Vse{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const rn=ke.define({combine(t){return pr(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Fse,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>t4(e(i),n(i)),optionClass:(e,n)=>i=>t4(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function t4(t,e){return t?e?t+" "+e:t:e}function Fse(t,e,n,i,r,s){let o=t.textDirection==yt.RTL,c=o,u=!1,h="top",d,m,g=e.left-r.left,y=r.right-e.right,x=i.right-i.left,w=i.bottom-i.top;if(c&&g<Math.min(x,y)?c=!1:!c&&y<Math.min(x,g)&&(c=!0),x<=(c?g:y))d=Math.max(r.top,Math.min(n.top,r.bottom-w))-e.top,m=Math.min(400,c?g:y);else{u=!0,m=Math.min(400,(o?e.right:r.right-e.left)-30);let A=r.bottom-e.bottom;A>=w||A>e.top?d=n.bottom-e.top:(h="bottom",d=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,C=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${d/S}px; max-width: ${m/C}px`,class:"cm-completionInfo-"+(u?o?"left-narrow":"right-narrow":c?"left":"right")}}const BC=je.define();function $se(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let c=n.displayLabel||n.label,u=0;for(let h=0;h<s.length;){let d=s[h++],m=s[h++];d>u&&o.appendChild(document.createTextNode(c.slice(u,d)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(d,m))),g.className="cm-completionMatchedText",u=m}return u<c.length&&o.appendChild(document.createTextNode(c.slice(u))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function _w(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class Gse{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,c=e.state.facet(rn);this.optionContent=$se(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=_w(s.length,o,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:h}=e.state.field(n).open;for(let d=u.target,m;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(m=/-(\d+)$/.exec(d.id))&&+m[1]<h.length){this.applyCompletion(e,h[+m[1]]),u.preventDefault();return}if(u.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&u.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&u.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:BC.of(d)}),u.preventDefault())}}),this.dom.addEventListener("focusout",u=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(rn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Au.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:c}=i.open;(!r.open||r.open.options!=s)&&(this.range=_w(s.length,o,e.state.facet(rn).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),c!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=_w(n.options.length,n.selected,this.view.state.facet(rn).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,r)}).catch(c=>Fn(this.view.state,c,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&Qse(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(rn).positionInfo(this.view,n,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:c,match:u}=e[o],{section:h}=c;if(h){let g=typeof h=="string"?h:h.name;if(g!=s&&(o>i.from||i.from==0))if(s=g,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let y=r.appendChild(document.createElement("completion-section"));y.textContent=g}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let m=this.optionClass(c);m&&(d.className=m);for(let g of this.optionContent){let y=g(c,this.view.state,this.view,u);y&&d.appendChild(y)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Yse(t,e){return n=>new Gse(n,t,e)}function Qse(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function n4(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Xse(t,e){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:m}=d.completion;if(m){i||(i=[]);let g=typeof m=="string"?m:m.name;i.some(y=>y.name==g)||i.push(typeof m=="string"?{name:g}:m)}},o=e.facet(rn);for(let d of t)if(d.hasResult()){let m=d.result.getMatch;if(d.result.filter===!1)for(let g of d.result.options)s(new J5(g,d.source,m?m(g):[],1e9-n.length));else{let g=e.sliceDoc(d.from,d.to),y,x=o.filterStrict?new Vse(g):new Use(g);for(let w of d.result.options)if(y=x.match(w.label)){let S=w.displayLabel?m?m(w,y.matched):[]:y.matched,C=y.score+(w.boost||0);if(s(new J5(w,d.source,S,C)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:A}=w.section;r||(r=Object.create(null)),r[A]=Math.max(C,r[A]||-1e9)}}}}if(i){let d=Object.create(null),m=0,g=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?r[x.name]-r[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name<x.name?-1:1);for(let y of i.sort(g))m-=1e5,d[y.name]=m;for(let y of n){let{section:x}=y.completion;x&&(y.score+=d[typeof x=="string"?x:x.name])}}let c=[],u=null,h=o.compareCompletions;for(let d of n.sort((m,g)=>g.score-m.score||h(m.completion,g.completion))){let m=d.completion;!u||u.label!=m.label||u.detail!=m.detail||u.type!=null&&m.type!=null&&u.type!=m.type||u.apply!=m.apply||u.boost!=m.boost?c.push(d):n4(d.completion)>n4(u)&&(c[c.length-1]=d),u=d.completion}return c}class Ko{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Ko(this.options,i4(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let c=Xse(e,n);if(!c.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let u=n.facet(rn).selectOnOpen?0:-1;if(r&&r.selected!=u&&r.selected!=-1){let h=r.options[r.selected].completion;for(let d=0;d<c.length;d++)if(c[d].completion==h){u=d;break}}return new Ko(c,i4(i,u),{pos:e.reduce((h,d)=>d.hasResult()?Math.min(h,d.from):h,1e8),create:tae,above:s.aboveCursor},r?r.timestamp:Date.now(),u,!1)}map(e){return new Ko(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ko(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sp{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new sp(Jse,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(rn),s=(i.override||n.languageDataAt("autocomplete",Ia(n)).map(Hse)).map(u=>(this.active.find(d=>d.source==u)||new Ai(u,this.active.some(d=>d.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((u,h)=>u==this.active[h])&&(s=this.active);let o=this.open,c=e.effects.some(u=>u.is(qC));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!Wse(s,this.active)||c?o=Ko.build(s,n,this.id,o,i,c):o&&o.disabled&&!s.some(u=>u.isPending)&&(o=null),!o&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new Ai(u.source,0):u));for(let u of e.effects)u.is(BC)&&(o=o&&o.setSelected(u.value,this.id));return s==this.active&&o==this.open?this:new sp(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kse:Zse}}function Wse(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const Kse={"aria-autocomplete":"list"},Zse={};function i4(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Jse=[];function vj(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(yj);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=vj(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Ai(r.source,0)),i&4&&r.state==0&&(r=new Ai(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(rp))r=new Ai(r.source,1,s.value);else if(s.is(Au))r=new Ai(r.source,0);else if(s.is(qC))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ia(e.state))}}class ll extends Ai{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),c=Ia(e.state);if(c>o||!r||n&2&&(Ia(e.startState)==this.from||c<this.limit))return new Ai(this.source,n&4?1:0);let u=e.changes.mapPos(this.limit);return eae(r.validFor,e.state,s,o)?new ll(this.source,this.explicit,u,r,s,o):r.update&&(r=r.update(r,s,o,new mj(e.state,c,!1)))?new ll(this.source,this.explicit,u,r,r.from,(i=r.to)!==null&&i!==void 0?i:Ia(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ll(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function eae(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):gj(t,!0).test(r)}const qC=je.define({map(t,e){return t.map(n=>n.map(e))}}),Pn=_n.define({create(){return sp.start()},update(t,e){return t.update(e)},provide:t=>[xC.from(t,e=>e.tooltip),Se.contentAttributes.from(t,e=>e.attrs)]});function jC(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(Pn).active.find(r=>r.source==e.source);return i instanceof ll?(typeof n=="string"?t.dispatch({...Pse(t.state,n,i.from,i.to),annotations:yj.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const tae=Yse(Pn,jC);function Jh(t,e="option"){return n=>{let i=n.state.field(Pn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(rn).interactionDelay)return!1;let r=1,s;e=="page"&&(s=K6(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,c=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return c<0?c=e=="page"?0:o-1:c>=o&&(c=e=="page"?o-1:0),n.dispatch({effects:BC.of(c)}),!0}}const nae=t=>{let e=t.state.field(Pn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(rn).interactionDelay?!1:jC(t,e.open.options[e.open.selected])},Ow=t=>t.state.field(Pn,!1)?(t.dispatch({effects:rp.of(!0)}),!0):!1,iae=t=>{let e=t.state.field(Pn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Au.of(null)}),!0)};class rae{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const sae=50,aae=1e3,oae=zt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Pn).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Pn),n=t.state.facet(rn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Pn)==e)return;let i=t.transactions.some(s=>{let o=vj(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>sae&&Date.now()-o.time>aae){for(let c of o.context.abortListeners)try{c()}catch(u){Fn(this.view.state,u)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(rp)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Pn);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Ia(e),i=new mj(e,n,t.explicit,this.view),r=new rae(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Au.of(null)}),Fn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(rn),i=this.view.state.field(Pn);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let c=Ia(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(c,s.done.from+(s.active.explicit?0:1)),h=new ll(s.active.source,s.active.explicit,u,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:c);for(let d of s.updates)h=h.update(d,n);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(c=>c.source==s.active.source);if(o&&o.isPending)if(s.done==null){let c=new Ai(s.active.source,0);for(let u of s.updates)c=c.update(u,n);c.isPending||e.push(c)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qC.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Pn,!1);if(e&&e.tooltip&&this.view.state.facet(rn).closeOnBlur){let n=e.open&&K6(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Au.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rp.of(!1)}),20),this.composing=0}}}),lae=typeof navigator=="object"&&/Win/.test(navigator.platform),cae=Za.highest(Se.domEventHandlers({keydown(t,e){let n=e.state.field(Pn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(lae&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&jC(e,i),!1}})),uae=Se.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),_u={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},La=je.define({map(t,e){let n=e.mapPos(t,-1,Rn.TrackAfter);return n??void 0}}),IC=new class extends Gs{};IC.startSide=1;IC.endSide=-1;const bj=_n.define({create(){return Ye.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of e.effects)n.is(La)&&(t=t.update({add:[IC.range(n.value,n.value+1)]}));return t}});function fae(){return[dae,bj]}const Ew="()[]{}<>«»»«[]{}";function xj(t){for(let e=0;e<Ew.length;e+=2)if(Ew.charCodeAt(e)==t)return Ew.charAt(e+1);return iC(t<128?t:t+1)}function wj(t,e){return t.languageDataAt("closeBrackets",e)[0]||_u}const hae=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dae=Se.inputHandler.of((t,e,n,i)=>{if((hae?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||i.length==2&&ir(In(i,0))==1||e!=r.from||n!=r.to)return!1;let s=gae(t.state,i);return s?(t.dispatch(s),!0):!1}),pae=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=wj(t,t.selection.main.head).brackets||_u.brackets,r=null,s=t.changeByRange(o=>{if(o.empty){let c=yae(t.doc,o.head);for(let u of i)if(u==c&&Wp(t.doc,o.head)==xj(In(u,0)))return{changes:{from:o.head-u.length,to:o.head+u.length},range:de.cursor(o.head-u.length)}}return{range:r=o}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mae=[{key:"Backspace",run:pae}];function gae(t,e){let n=wj(t,t.selection.main.head),i=n.brackets||_u.brackets;for(let r of i){let s=xj(In(r,0));if(e==r)return s==r?xae(t,r,i.indexOf(r+r+r)>-1,n):vae(t,r,s,n.before||_u.before);if(e==s&&Sj(t,t.selection.main.from))return bae(t,r,s)}return null}function Sj(t,e){let n=!1;return t.field(bj).between(0,t.doc.length,i=>{i==e&&(n=!0)}),n}function Wp(t,e){let n=t.sliceString(e,e+2);return n.slice(0,ir(In(n,0)))}function yae(t,e){let n=t.sliceString(e-2,e);return ir(In(n,0))==n.length?n:n.slice(1)}function vae(t,e,n,i){let r=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:La.of(o.to+e.length),range:de.range(o.anchor+e.length,o.head+e.length)};let c=Wp(t.doc,o.head);return!c||/\s/.test(c)||i.indexOf(c)>-1?{changes:{insert:e+n,from:o.head},effects:La.of(o.head+e.length),range:de.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bae(t,e,n){let i=null,r=t.changeByRange(s=>s.empty&&Wp(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:de.cursor(s.head+n.length)}:i={range:s});return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function xae(t,e,n,i){let r=i.stringPrefixes||_u.stringPrefixes,s=null,o=t.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:La.of(c.to+e.length),range:de.range(c.anchor+e.length,c.head+e.length)};let u=c.head,h=Wp(t.doc,u),d;if(h==e){if(r4(t,u))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(Sj(t,u)){let g=n&&t.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:de.cursor(u+g.length)}}}else{if(n&&t.sliceDoc(u-2*e.length,u)==e+e&&(d=s4(t,u-2*e.length,r))>-1&&r4(t,d))return{changes:{insert:e+e+e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(t.charCategorizer(u)(h)!=At.Word&&s4(t,u,r)>-1&&!wae(t,u,e,r))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)}}return{range:s=c}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function r4(t,e){let n=Cn(t).resolveInner(e+1);return n.parent&&n.from==e}function wae(t,e,n,i){let r=Cn(t).resolveInner(e,-1),s=i.reduce((o,c)=>Math.max(o,c.length),0);for(let o=0;o<5;o++){let c=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),u=c.indexOf(n);if(!u||u>-1&&i.indexOf(c.slice(0,u))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+u;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function s4(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=At.Word)return e;for(let r of n){let s=e-r.length;if(t.sliceDoc(s,e)==r&&i(t.sliceDoc(s-1,s))!=At.Word)return s}return-1}function Sae(t={}){return[cae,Pn,rn.of(t),oae,Cae,uae]}const Cj=[{key:"Ctrl-Space",run:Ow},{mac:"Alt-`",run:Ow},{mac:"Alt-i",run:Ow},{key:"Escape",run:iae},{key:"ArrowDown",run:Jh(!0)},{key:"ArrowUp",run:Jh(!1)},{key:"PageDown",run:Jh(!0,"page")},{key:"PageUp",run:Jh(!1,"page")},{key:"Enter",run:nae}],Cae=Za.highest(Hp.computeN([rn],t=>t.facet(rn).defaultKeymap?[Cj]:[]));class a4{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class Ea{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let r=i.facet(Ou).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),o=new Kr,c=[],u=0,h=i.doc.iter(),d=0,m=i.doc.length;for(let y=0;;){let x=y==s.length?null:s[y];if(!x&&!c.length)break;let w,S;if(c.length)w=u,S=c.reduce((O,E)=>Math.min(O,E.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>m)break;S=x.to,c.push(x),y++}for(;y<s.length;){let O=s[y];if(O.from==w&&(O.to>O.from||O.to==w))c.push(O),y++,S=Math.min(O.to,S);else{S=Math.min(O.from,S);break}}S=Math.min(S,m);let C=!1;if(c.some(O=>O.from==w&&(O.to==S||S==m))&&(C=w==S,!C&&S-w<10)){let O=w-(d+h.value.length);O>0&&(h.next(O),d=w);for(let E=w;;){if(E>=S){C=!0;break}if(!h.lineBreak&&d+h.value.length>E)break;E=d+h.value.length,d+=h.value.length,h.next()}}let A=Bae(c);if(C)o.add(w,w,Le.widget({widget:new Nae(A),diagnostics:c.slice()}));else{let O=c.reduce((E,T)=>T.markClass?E+" "+T.markClass:E,"");o.add(w,S,Le.mark({class:"cm-lintRange cm-lintRange-"+A+O,diagnostics:c.slice(),inclusiveEnd:c.some(E=>E.to>S)}))}if(u=S,u==m)break;for(let O=0;O<c.length;O++)c[O].to<=u&&c.splice(O--,1)}let g=o.finish();return new Ea(g,n,Zs(g))}}function Zs(t,e=null,n=0){let i=null;return t.between(n,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new a4(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new a4(i.from,s,i.diagnostic)}}),i}function kae(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(Ou).hideOn(t,n,i);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(kj))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function Aae(t,e){return t.field(oi,!1)?e:e.concat(je.appendConfig.of(qae))}const kj=je.define(),PC=je.define(),Aj=je.define(),oi=_n.define({create(){return new Ea(Le.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=Zs(n,t.selected.diagnostic,s)||Zs(n,null,s)}!n.size&&r&&e.state.facet(Ou).autoPanel&&(r=null),t=new Ea(n,r,i)}for(let n of e.effects)if(n.is(kj)){let i=e.state.facet(Ou).autoPanel?n.value.length?Eu.open:null:t.panel;t=Ea.init(n.value,i,e.state)}else n.is(PC)?t=new Ea(t.diagnostics,n.value?Eu.open:null,t.selected):n.is(Aj)&&(t=new Ea(t.diagnostics,t.panel,n.value));return t},provide:t=>[xu.from(t,e=>e.panel),Se.decorations.from(t,e=>e.diagnostics)]}),_ae=Le.mark({class:"cm-lintRange cm-lintRange-active"});function Oae(t,e,n){let{diagnostics:i}=t.state.field(oi),r,s=-1,o=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(u,h,{spec:d})=>{if(e>=u&&e<=h&&(u==h||(e>u||n>0)&&(e<h||n<0)))return r=d.diagnostics,s=u,o=h,!1});let c=t.state.facet(Ou).tooltipFilter;return r&&c&&(r=c(r,t.state)),r?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Eae(t,r)}}}:null}function Eae(t,e){return dt("ul",{class:"cm-tooltip-lint"},e.map(n=>Oj(t,n,!1)))}const Tae=t=>{let e=t.state.field(oi,!1);(!e||!e.panel)&&t.dispatch({effects:Aae(t.state,[PC.of(!0)])});let n=wC(t,Eu.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},o4=t=>{let e=t.state.field(oi,!1);return!e||!e.panel?!1:(t.dispatch({effects:PC.of(!1)}),!0)},Mae=t=>{let e=t.state.field(oi,!1);if(!e)return!1;let n=t.state.selection.main,i=Zs(e.diagnostics,null,n.to+1);return!i&&(i=Zs(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Rae=[{key:"Mod-Shift-m",run:Tae,preventDefault:!0},{key:"F8",run:Mae}],Ou=ke.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...pr(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:l4,tooltipFilter:l4,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,r,s)=>e(i,r,s)||n(i,r,s):e:n,autoPanel:(e,n)=>e||n})}}});function l4(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function _j(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let r=n[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Oj(t,e,n){var i;let r=n?_j(e.actions):[];return dt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},dt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let c=!1,u=y=>{if(y.preventDefault(),c)return;c=!0;let x=Zs(t.state.field(oi).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:h}=s,d=r[o]?h.indexOf(r[o]):-1,m=d<0?h:[h.slice(0,d),dt("u",h.slice(d,d+1)),h.slice(d+1)],g=s.markClass?" "+s.markClass:"";return dt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${h}${d<0?"":` (access key "${r[o]})"`}.`},m)}),e.source&&dt("div",{class:"cm-diagnosticSource"},e.source))}class Nae extends mr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return dt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class c4{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Oj(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Eu{constructor(e){this.view=e,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)o4(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=_j(s.actions);for(let c=0;c<o.length;c++)if(o[c].toUpperCase().charCodeAt(0)==r.keyCode){let u=Zs(this.view.state.field(oi).diagnostics,s);u&&s.actions[c].apply(e,u.from,u.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=dt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=dt("div",{class:"cm-panel-lint"},this.list,dt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>o4(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(oi).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(oi),i=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(c,u,{spec:h})=>{for(let d of h.diagnostics){if(o.has(d))continue;o.add(d);let m=-1,g;for(let y=i;y<this.items.length;y++)if(this.items[y].diagnostic==d){m=y;break}m<0?(g=new c4(this.view,d),this.items.splice(i,0,g),r=!0):(g=this.items[m],m>i&&(this.items.splice(i,m-i),r=!0)),n&&g.diagnostic==n.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new c4(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:c,panel:u})=>{let h=u.height/this.list.offsetHeight;c.top<u.top?this.list.scrollTop-=(u.top-c.top)/h:c.bottom>u.bottom&&(this.list.scrollTop+=(c.bottom-u.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(oi),i=Zs(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Aj.of(i)})}static open(e){return new Eu(e)}}function Dae(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function ed(t){return Dae(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Lae=Se.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:ed("#d11")},".cm-lintRange-warning":{backgroundImage:ed("orange")},".cm-lintRange-info":{backgroundImage:ed("#999")},".cm-lintRange-hint":{backgroundImage:ed("#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 zae(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Bae(t){let e="hint",n=1;for(let i of t){let r=zae(i.severity);r>n&&(n=r,e=i.severity)}return e}const qae=[oi,Se.decorations.compute([oi],t=>{let{selected:e,panel:n}=t.field(oi);return!e||!n||e.from==e.to?Le.none:Le.set([_ae.range(e.from,e.to)])}),One(Oae,{hideOn:kae}),Lae];var u4=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(mae)),e.defaultKeymap!==!1&&(i=i.concat(ose)),e.searchKeymap!==!1&&(i=i.concat(Lse)),e.historyKeymap!==!1&&(i=i.concat(pre)),e.foldKeymap!==!1&&(i=i.concat(Eie)),e.completionKeymap!==!1&&(i=i.concat(Cj)),e.lintKeymap!==!1&&(i=i.concat(Rae));var r=[];return e.lineNumbers!==!1&&r.push(Pne()),e.highlightActiveLineGutter!==!1&&r.push(Vne()),e.highlightSpecialChars!==!1&&r.push(nne()),e.history!==!1&&r.push(sre()),e.foldGutter!==!1&&r.push(Nie()),e.drawSelection!==!1&&r.push($te()),e.dropCursor!==!1&&r.push(Wte()),e.allowMultipleSelections!==!1&&r.push(Je.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(vie()),e.syntaxHighlighting!==!1&&r.push(kq(Bie,{fallback:!0})),e.bracketMatching!==!1&&r.push(Vie()),e.closeBrackets!==!1&&r.push(fae()),e.autocompletion!==!1&&r.push(Sae()),e.rectangularSelection!==!1&&r.push(gne()),n!==!1&&r.push(bne()),e.highlightActiveLine!==!1&&r.push(lne()),e.highlightSelectionMatches!==!1&&r.push(dse()),e.tabSize&&typeof e.tabSize=="number"&&r.push(Vp.of(" ".repeat(e.tabSize))),r.concat([Hp.of(i.flat())]).filter(Boolean)};const jae="#e5c07b",f4="#e06c75",Iae="#56b6c2",Pae="#ffffff",dd="#abb2bf",n2="#7d8799",Hae="#61afef",Uae="#98c379",h4="#d19a66",Vae="#c678dd",Fae="#21252b",d4="#2c313a",p4="#282c34",Tw="#353a42",$ae="#3E4451",m4="#528bff",Gae=Se.theme({"&":{color:dd,backgroundColor:p4},".cm-content":{caretColor:m4},".cm-cursor, .cm-dropCursor":{borderLeftColor:m4},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$ae},".cm-panels":{backgroundColor:Fae,color:dd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:p4,color:n2,border:"none"},".cm-activeLineGutter":{backgroundColor:d4},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Tw},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Tw,borderBottomColor:Tw},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:d4,color:dd}}},{dark:!0}),Yae=$u.define([{tag:le.keyword,color:Vae},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:f4},{tag:[le.function(le.variableName),le.labelName],color:Hae},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:h4},{tag:[le.definition(le.name),le.separator],color:dd},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:jae},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:Iae},{tag:[le.meta,le.comment],color:n2},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:n2,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:f4},{tag:[le.atom,le.bool,le.special(le.variableName)],color:h4},{tag:[le.processingInstruction,le.string,le.inserted],color:Uae},{tag:le.invalid,color:Pae}]),Ej=[Gae,kq(Yae)];var Qae=Se.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Xae=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:c=!0}=e,u=[];switch(n&&u.unshift(Hp.of([lse])),c&&(typeof c=="boolean"?u.unshift(u4()):u.unshift(u4(c))),o&&u.unshift(hne(o)),s){case"light":u.push(Qae);break;case"dark":u.push(Ej);break;case"none":break;default:u.push(s);break}return i===!1&&u.push(Se.editable.of(!1)),r&&u.push(Je.readOnly.of(!0)),[...u]},Wae=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Kae{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class g4{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Mw=null,Zae=()=>typeof window>"u"?new g4:(Mw||(Mw=new g4),Mw),y4=dr.define(),Jae=200,eoe=[];function toe(t){var{value:e,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:c=eoe,autoFocus:u,theme:h="light",height:d=null,minHeight:m=null,maxHeight:g=null,width:y=null,minWidth:x=null,maxWidth:w=null,placeholder:S="",editable:C=!0,readOnly:A=!1,indentWithTab:O=!0,basicSetup:E=!0,root:T,initialState:M}=t,[R,z]=j.useState(),[q,U]=j.useState(),[P,$]=j.useState(),K=j.useState(()=>({current:null}))[0],L=j.useState(()=>({current:null}))[0],Y=Se.theme({"&":{height:d,minHeight:m,maxHeight:g,width:y,minWidth:x,maxWidth:w},"& .cm-scroller":{height:"100% !important"}}),D=Se.updateListener.of(G=>{if(G.docChanged&&typeof i=="function"&&!G.transactions.some(F=>F.annotation(y4))){K.current?K.current.reset():(K.current=new Kae(()=>{if(L.current){var F=L.current;L.current=null,F()}K.current=null},Jae),Zae().add(K.current));var W=G.state.doc,B=W.toString();i(B,G)}r&&r(Wae(G))}),Q=Xae({theme:h,editable:C,readOnly:A,placeholder:S,indentWithTab:O,basicSetup:E}),ee=[D,Y,...Q];return o&&typeof o=="function"&&ee.push(Se.updateListener.of(o)),ee=ee.concat(c),j.useLayoutEffect(()=>{if(R&&!P){var G={doc:e,selection:n,extensions:ee},W=M?Je.fromJSON(M.json,G,M.fields):Je.create(G);if($(W),!q){var B=new Se({state:W,parent:R,root:T});U(B),s&&s(B,W)}}return()=>{q&&($(void 0),U(void 0))}},[R,P]),j.useEffect(()=>{t.container&&z(t.container)},[t.container]),j.useEffect(()=>()=>{q&&(q.destroy(),U(void 0)),K.current&&(K.current.cancel(),K.current=null)},[q]),j.useEffect(()=>{u&&q&&q.focus()},[u,q]),j.useEffect(()=>{q&&q.dispatch({effects:je.reconfigure.of(ee)})},[h,c,d,m,g,y,x,w,S,C,A,O,E,i,o]),j.useEffect(()=>{if(e!==void 0){var G=q?q.state.doc.toString():"";if(q&&e!==G){var W=K.current&&!K.current.isDone,B=()=>{q&&e!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:e||""},annotations:[y4.of(!0)]})};W?L.current=B:B()}}},[e,q]),{state:P,setState:$,view:q,setView:U,container:R,setContainer:z}}var noe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Tj=j.forwardRef((t,e)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:m="light",height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,root:R,initialState:z}=t,q=NJ(t,noe),U=j.useRef(null),{state:P,view:$,container:K,setContainer:L}=toe({root:R,value:i,autoFocus:d,theme:m,height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,selection:r,onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:s,initialState:z});j.useImperativeHandle(e,()=>({editor:U.current,state:P,view:$}),[U,K,P,$]);var Y=j.useCallback(Q=>{U.current=Q,L(Q)},[L]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return k.jsx("div",cS({ref:Y,className:""+D+(n?" "+n:"")},q))});Tj.displayName="CodeMirror";var v4={};class ap{constructor(e,n,i,r,s,o,c,u,h,d=0,m){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=c,this.bufferBase=u,this.curContext=h,this.lookAhead=d,this.parent=m}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new ap(e,[],n,i,i,0,[],0,r?new b4(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),c=s.dynamicPrecedence(r);if(c&&(this.score+=c),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let u=this.stack.length-(i-1)*3-(e&262144?6:0),h=u?this.stack[u-2]:this.p.ranges[0].from,d=this.reducePos-h;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=d));let m=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-m;if(r<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,y,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let y=this.stack[u-3];this.state=s.getGoto(y,r,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,c=this.buffer.length;if(c==0&&o.parent&&(c=o.bufferBase-o.parent.bufferBase,o=o.parent),c>0&&o.buffer[c-4]==0&&o.buffer[c-1]>-1){if(n==i)return;if(o.buffer[c-2]>=n){o.buffer[c-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let c=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){c=!0;break}if(c)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let c=o.stateFlag(s,1);!c&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,c?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,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,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new ap(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new ioe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((c,u)=>u&1&&c==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let c=(o>>19)-s;if(c>1){let u=o&65535,h=this.stack.length-c*3;if(h>=0&&e.getGoto(this.stack[h],u,!1)>=0)return c<<19|65536|u}}else{let c=i(o,s+1);if(c!=null)return c}})};return i(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 n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}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 n=new b4(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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()}}class b4{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class ioe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class op{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new op(e,n,n-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 op(this.stack,this.pos,this.index)}}function td(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),c=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,c=!0),s+=u,c)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class pd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const x4=new pd;class roe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=x4,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,c=this.range;for(;c.to<=i;)c=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>c.to&&(this.chunk2=this.chunk2.slice(0,c.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=x4,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class cl{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;soe(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}cl.prototype.contextual=cl.prototype.fallback=cl.prototype.extend=!1;cl.prototype.fallback=cl.prototype.extend=!1;class Kp{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function soe(t,e,n,i,r,s){let o=0,c=1<<i,{dialect:u}=n.p.parser;e:for(;(c&t[o])!=0;){let h=t[o+1];for(let y=o+3;y<h;y+=2)if((t[y+1]&c)>0){let x=t[y];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||aoe(x,e.token.value,r,s))){e.acceptToken(x);break}}let d=e.next,m=0,g=t[o+2];if(e.next<0&&g>m&&t[h+g*3-3]==65535){o=t[h+g*3-1];continue e}for(;m<g;){let y=m+g>>1,x=h+y+(y<<1),w=t[x],S=t[x+1]||65536;if(d<w)g=y;else if(d>=S)m=y+1;else{o=t[x+2],e.advance();continue e}}break}}function w4(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function aoe(t,e,n,i){let r=w4(n,i,e);return r<0||w4(n,i,t)<r}const si=typeof process<"u"&&v4&&/\bparse\b/.test(v4.LOG);let Rw=null;function S4(t,e,n){let i=t.cursor(Nt.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class ooe{constructor(e,n){this.fragments=e,this.nodeSet=n,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?S4(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?S4(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof It){if(o==e){if(o<this.safeFrom)return null;let c=o+s.length;if(c<=this.safeTo){let u=s.prop(Fe.lookAhead);if(!u||c+u<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class loe{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new pd)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,u=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let d=s[h],m=this.tokens[h];if(!(i&&!d.fallback)&&((d.contextual||m.start!=e.pos||m.mask!=o||m.context!=c)&&(this.updateCachedToken(m,d,e),m.mask=o,m.context=c),m.lookAhead>m.end+25&&(u=Math.max(m.lookAhead,u)),m.value!=0)){let g=n;if(m.extended>-1&&(n=this.addActions(e,m.extended,m.end,n)),n=this.addActions(e,m.value,m.end,n),!d.extend&&(i=m,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new pd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new pd,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let c=s.specializers[o](this.stream.read(e.start,e.end),i);if(c>=0&&i.p.parser.dialect.allows(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:c}=o;for(let u=0;u<2;u++)for(let h=o.stateSlot(s,u?2:1);;h+=3){if(c[h]==65535)if(c[h+1]==1)h=Vr(c,h+2);else{r==0&&c[h+1]==2&&(r=this.putAction(Vr(c,h+2),n,i,r));break}c[h]==n&&(r=this.putAction(Vr(c,h+1),n,i,r))}return r}}class coe{constructor(e,n,i,r){this.parser=e,this.input=n,this.ranges=r,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 roe(n,r),this.tokens=new loe(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ap.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new ooe(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let c=e[o];for(;;){if(this.tokens.mainToken=null,c.pos>n)i.push(c);else{if(this.advanceStack(c,i,e))continue;{r||(r=[],s=[]),r.push(c);let u=this.tokens.getMainToken(c);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&hoe(r);if(o)return si&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw si&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return si&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((c,u)=>u.score-c.score);i.length>o;)i.pop();i.some(c=>c.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let c=i[o];for(let u=o+1;u<i.length;u++){let h=i[u];if(c.sameState(h)||c.buffer.length>500&&h.buffer.length>500)if((c.score-h.score||c.buffer.length-h.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,c)=>c.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].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,n,i){let r=e.pos,{parser:s}=this,o=si?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,d=h?e.curContext.hash:0;for(let m=this.fragments.nodeAt(r);m;){let g=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(g>-1&&m.length&&(!h||(m.prop(Fe.contextHash)||0)==d))return e.useNode(m,g),si&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof It)||m.children.length==0||m.positions[0]>0)break;let y=m.children[0];if(y instanceof It&&m.positions[0]==0)m=y;else break}}let c=s.stateSlot(e.state,4);if(c>0)return e.reduce(c),si&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let h=0;h<u.length;){let d=u[h++],m=u[h++],g=u[h++],y=h==u.length||!i,x=y?e:e.split(),w=this.tokens.mainToken;if(x.apply(d,m,w?w.start:x.pos,g),si&&console.log(o+this.stackID(x)+` (via ${(d&65536)==0?"shift":`reduce of ${s.getName(d&65535)}`} for ${s.getName(m)} @ ${r}${x==e?"":", split"})`),y)return!0;x.pos>r?n.push(x):i.push(x)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return C4(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o],u=n[o<<1],h=n[(o<<1)+1],d=si?this.stackID(c)+" -> ":"";if(c.deadEnd&&(s||(s=!0,c.restart(),si&&console.log(d+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let m=c.split(),g=d;for(let y=0;y<10&&m.forceReduce()&&(si&&console.log(g+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));y++)si&&(g=this.stackID(m)+" -> ");for(let y of c.recoverByInsert(u))si&&console.log(d+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>c.pos?(h==c.pos&&(h++,u=0),c.recoverByDelete(u,h),si&&console.log(d+this.stackID(c)+` (via recover-delete ${this.parser.getName(u)})`),C4(c,i)):(!r||r.score<m.score)&&(r=m)}return r}stackToTree(e){return e.close(),It.build({buffer:op.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 n=(Rw||(Rw=new WeakMap)).get(e);return n||Rw.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function C4(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class uoe{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Nw=t=>t;class foe{constructor(e){this.start=e.start,this.shift=e.shift||Nw,this.reduce=e.reduce||Nw,this.reuse=e.reuse||Nw,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class lp extends oq{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;c<e.repeatNodeCount;c++)n.push("");let i=Object.keys(e.topRules).map(c=>e.topRules[c][1]),r=[];for(let c=0;c<n.length;c++)r.push([]);function s(c,u,h){r[c].push([u,u.deserialize(String(h))])}if(e.nodeProps)for(let c of e.nodeProps){let u=c[0];typeof u=="string"&&(u=Fe[u]);for(let h=1;h<c.length;){let d=c[h++];if(d>=0)s(d,u,c[h++]);else{let m=c[h+-d];for(let g=-d;g>0;g--)s(c[h++],u,m);h++}}}this.nodeSet=new SC(n.map((c,u)=>Xn.define({name:u>=this.minRepeatTerm?void 0:c,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iq;let o=td(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;c<this.specializerSpecs.length;c++)this.specialized[c]=this.specializerSpecs[c].term;this.specializers=this.specializerSpecs.map(k4),this.states=td(e.states,Uint32Array),this.data=td(e.stateData),this.goto=td(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(c=>typeof c=="number"?new cl(o,c):c),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,n,i){let r=new coe(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],c=o&1,u=r[s++];if(c&&i)return u;for(let h=s+(o>>1);s<h;s++)if(r[s]==e)return u;if(c)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Vr(i,s+2)];else{if(i[s+1]==2)return Vr(i,s+2);break}if(o==n||o==0)return Vr(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vr(this.data,s+2);else break;r=n(Vr(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Vr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(lp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(c=>c.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=k4(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}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 n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],c;(c=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[c]=1;return new uoe(e,i,r)}static deserialize(e){return new lp(e)}}function Vr(t,e){return t[e]|t[e+1]<<16}function hoe(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function k4(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}const Uo=63,A4=64,doe=1,poe=2,Mj=3,moe=4,Rj=5,goe=6,yoe=7,Nj=65,voe=66,boe=8,xoe=9,woe=10,Soe=11,Coe=12,Dj=13,koe=19,Aoe=20,_oe=29,Ooe=33,Eoe=34,Toe=47,Moe=0,HC=1,i2=2,Tu=3,r2=4;class Ta{constructor(e,n,i){this.parent=e,this.depth=n,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+n+(n<<4)+i}}Ta.top=new Ta(null,-1,Moe);function eu(t,e){for(let n=0,i=e-t.pos-1;;i--,n++){let r=t.peek(i);if(es(r)||r==-1)return n}}function s2(t){return t==32||t==9}function es(t){return t==10||t==13}function Lj(t){return s2(t)||es(t)}function za(t){return t<0||Lj(t)}const Roe=new foe({start:Ta.top,reduce(t,e){return t.type==Tu&&(e==Aoe||e==Eoe)?t.parent:t},shift(t,e,n,i){if(e==Mj)return new Ta(t,eu(i,i.pos),HC);if(e==Nj||e==Rj)return new Ta(t,eu(i,i.pos),i2);if(e==Uo)return t.parent;if(e==koe||e==Ooe)return new Ta(t,0,Tu);if(e==Dj&&t.type==r2)return t.parent;if(e==Toe){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Ta(t,t.depth+ +r[0],r2)}return t},hash(t){return t.hash}});function xl(t,e,n=0){return t.peek(n)==e&&t.peek(n+1)==e&&t.peek(n+2)==e&&za(t.peek(n+3))}const Noe=new Kp((t,e)=>{if(t.next==-1&&e.canShift(A4))return t.acceptToken(A4);let n=t.peek(-1);if((es(n)||n<0)&&e.context.type!=Tu){if(xl(t,45))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(doe,3);if(xl(t,46))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(poe,3);let i=0;for(;t.next==32;)i++,t.advance();(i<e.context.depth||i==e.context.depth&&e.context.type==HC&&(t.next!=45||!za(t.peek(1))))&&t.next!=-1&&!es(t.next)&&t.next!=35&&t.acceptToken(Uo,-i)}},{contextual:!0}),Doe=new Kp((t,e)=>{if(e.context.type==Tu){t.next==63&&(t.advance(),za(t.next)&&t.acceptToken(yoe));return}if(t.next==45)t.advance(),za(t.next)&&t.acceptToken(e.context.type==HC&&e.context.depth==eu(t,t.pos-1)?moe:Mj);else if(t.next==63)t.advance(),za(t.next)&&t.acceptToken(e.context.type==i2&&e.context.depth==eu(t,t.pos-1)?goe:Rj);else{let n=t.pos;for(;;)if(s2(t.next)){if(t.pos==n)return;t.advance()}else if(t.next==33)zj(t);else if(t.next==38)a2(t);else if(t.next==42){a2(t);break}else if(t.next==39||t.next==34){if(UC(t,!0))break;return}else if(t.next==91||t.next==123){if(!zoe(t))return;break}else{Bj(t,!0,!1,0);break}for(;s2(t.next);)t.advance();if(t.next==58){if(t.pos==n&&e.canShift(_oe))return;let i=t.peek(1);za(i)&&t.acceptTokenTo(e.context.type==i2&&e.context.depth==eu(t,n)?voe:Nj,n)}}},{contextual:!0});function Loe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function _4(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function O4(t,e){return t.next==37?(t.advance(),_4(t.next)&&t.advance(),_4(t.next)&&t.advance(),!0):Loe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function zj(t){if(t.advance(),t.next==60){for(t.advance();;)if(!O4(t,!0)){t.next==62&&t.advance();break}}else for(;O4(t,!1););}function a2(t){for(t.advance();!za(t.next)&&cp(t.next)!="f";)t.advance()}function UC(t,e){let n=t.next,i=!1,r=t.pos;for(t.advance();;){let s=t.next;if(s<0)break;if(t.advance(),s==n)if(s==39)if(t.next==39)t.advance();else break;else break;else if(s==92&&n==34)t.next>=0&&t.advance();else if(es(s)){if(e)return!1;i=!0}else if(e&&t.pos>=r+1024)return!1}return!i}function zoe(t){for(let e=[],n=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!UC(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>n||es(t.next))return!1;t.advance()}}const Boe="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function cp(t){return t<33?"u":t>125?"s":Boe[t-33]}function Dw(t,e){let n=cp(t);return n!="u"&&!(e&&n=="f")}function Bj(t,e,n,i){if(cp(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&Dw(t.peek(1),n))t.advance();else return!1;let r=t.pos;for(;;){let s=t.next,o=0,c=i+1;for(;Lj(s);){if(es(s)){if(e)return!1;c=0}else c++;s=t.peek(++o)}if(!(s>=0&&(s==58?Dw(t.peek(o+1),n):s==35?t.peek(o-1)!=32:Dw(s,n)))||!n&&c<=i||c==0&&!n&&(xl(t,45,o)||xl(t,46,o)))break;if(e&&cp(s)=="f")return!1;for(let h=o;h>=0;h--)t.advance();if(e&&t.pos>r+1024)return!1}return!0}const qoe=new Kp((t,e)=>{if(t.next==33)zj(t),t.acceptToken(Coe);else if(t.next==38||t.next==42){let n=t.next==38?woe:Soe;a2(t),t.acceptToken(n)}else t.next==39||t.next==34?(UC(t,!1),t.acceptToken(xoe)):Bj(t,!1,e.context.type==Tu,e.context.depth)&&t.acceptToken(boe)}),joe=new Kp((t,e)=>{let n=e.context.type==r2?e.context.depth:-1,i=t.pos;e:for(;;){let r=0,s=t.next;for(;s==32;)s=t.peek(++r);if(!r&&(xl(t,45,r)||xl(t,46,r))||!es(s)&&(n<0&&(n=Math.max(e.context.depth+1,r)),r<n))break;for(;;){if(t.next<0)break e;let o=es(t.next);if(t.advance(),o)continue e;i=t.pos}}t.acceptTokenTo(Dj,i)}),Ioe=lq({DirectiveName:le.keyword,DirectiveContent:le.attributeValue,"DirectiveEnd DocEnd":le.meta,QuotedLiteral:le.string,BlockLiteralHeader:le.special(le.string),BlockLiteralContent:le.content,Literal:le.content,"Key/Literal Key/QuotedLiteral":le.definition(le.propertyName),"Anchor Alias":le.labelName,Tag:le.typeName,Comment:le.lineComment,": , -":le.separator,"?":le.punctuation,"[ ]":le.squareBracket,"{ }":le.brace}),Poe=lp.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Roe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Ioe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Noe,Doe,qoe,joe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Hoe=Gd.define({name:"yaml",parser:Poe.configure({props:[hq.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let n=t.column(e.from,1);if(n==t.lineIndent(e.from,1))return n;if(e.to>t.pos)return null}}return null},FlowMapping:L5({closing:"}"}),FlowSequence:L5({closing:"]"})}),mq.add({"FlowMapping FlowSequence":xie,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Uoe(){return new cie(Hoe)}const Voe=()=>{const{error:t,isCliMode:e,yamlInput:n,setYamlInput:i,parseAndSetSchema:r,isAutoSaveEnabled:s,setIsAutoSaveEnabled:o,savingStatus:c,saveSchema:u,lastUpdateSource:h,theme:d}=ci(),[m,g]=j.useState(n),y=j.useRef(null),x=j.useRef(null),w=j.useRef(!0);j.useEffect(()=>{if(!x.current?.view)return;const E=x.current.view,T=E.state.doc.toString();if(w.current&&n){E.dispatch({changes:{from:0,to:T.length,insert:n},annotations:Qt.addToHistory.of(!1)}),g(n),w.current=!1;return}h==="visual"&&T!==n&&(E.dispatch({changes:{from:0,to:T.length,insert:n},userEvent:"visual-edit"}),g(n))},[n,h]);const S=j.useCallback(E=>{g(E),!(!E||E.trim()==="")&&(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{i(E),r(E)},300))},[i,r]),C=async()=>{r(m),e&&await u(!0)},A=()=>{x.current?.view&&MC(x.current.view)},O=()=>{x.current?.view&&Kd(x.current.view)};return k.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full",children:[k.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?k.jsxs("div",{className:"flex items-center gap-4",children:[k.jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",children:[k.jsx("div",{className:`relative w-7 h-4 rounded-full transition-colors ${s?"bg-blue-600":"bg-slate-300 dark:bg-slate-700"}`,onClick:()=>o(!s),children:k.jsx("div",{className:`absolute top-0.5 left-0.5 w-3 h-3 bg-white rounded-full transition-transform ${s?"translate-x-3":"translate-x-0"}`})}),k.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${d==="dark"?"text-slate-500 group-hover:text-slate-400":"text-slate-400 group-hover:text-slate-600"}`,children:"Auto-save"})]}),k.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[c==="saving"&&k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[k.jsx(xK,{size:10,className:"animate-spin"}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),c==="saved"&&k.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[k.jsx(nK,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),c==="error"&&k.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[k.jsx(K1,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):k.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[k.jsx(K1,{size:12,className:"text-blue-400"}),k.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsxs("div",{className:`flex rounded-lg p-0.5 border ${d==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[k.jsx("button",{onClick:A,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:k.jsx(Y8,{size:14})}),k.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${d==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),k.jsx("button",{onClick:O,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:k.jsx($8,{size:14})})]}),k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[k.jsx(mK,{size:12}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),k.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${d==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[k.jsx(Tj,{ref:x,value:m,height:"100%",theme:d==="dark"?Ej:"light",extensions:[Uoe()],onChange:S,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&m===n&&k.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[k.jsx(K1,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),k.jsx("span",{children:t})]})]}),k.jsxs("div",{className:"flex justify-between items-center pt-1 shrink-0",children:[k.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?s?"Changes save automatically":"Click save to update file":"Changes reset on reload"}),k.jsxs("button",{onClick:C,disabled:c==="saving",className:`flex items-center gap-2 px-4 py-2 rounded-md font-medium text-sm transition-all shadow-lg shrink-0 ${e?s?"bg-slate-300 dark:bg-slate-700 text-slate-500 dark:text-slate-400 cursor-not-allowed opacity-50":"bg-blue-600 hover:bg-blue-700 text-white":"bg-emerald-600 hover:bg-emerald-700 text-white"}`,children:[e?k.jsx(UK,{size:16}):k.jsx(BK,{size:16}),e?"Save & Update":"Apply Changes"]})]})]})},Foe=()=>{const{schema:t,setSelectedTableId:e,setFocusNodeId:n,theme:i}=ci(),[r,s]=j.useState(""),[o,c]=j.useState(new Set),u=m=>{const g=new Set(o);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{e(m),n(m)},d=j.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const S=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&S&&(m[S.id].push(w),g.add(w.id))});const y=(t.domains||[]).filter(w=>{const S=m[w.id].length>0,C=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return S||C&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(C=>C.tables.includes(w.id)));return{domains:y,unassigned:x}},[t,r]);return t?k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 pt-2",children:[k.jsxs("div",{className:"relative mb-4 shrink-0",children:[k.jsx(FK,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),k.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),placeholder:"Search entities...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),k.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=o.has(m.id);return k.jsxs("section",{className:"flex flex-col",children:[k.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u(m.id),children:[k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.tables.length})]}),k.jsx("button",{onClick:y=>{y.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",title:"Focus on Domain",children:k.jsx(W1,{size:12})})]}),!g&&k.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(y=>k.jsxs("button",{onClick:()=>h(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:y.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},y.id)),m.tables.length===0&&k.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables in this domain"})]})]},m.id)}),d.unassigned.length>0&&k.jsxs("section",{className:"flex flex-col",children:[k.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u("unassigned"),children:k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx(F8,{size:12,className:"text-slate-500 shrink-0"}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:d.unassigned.length})]})}),!o.has("unassigned")&&k.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>k.jsxs("button",{onClick:()=>h(m.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:m.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]}),d.domains.length===0&&d.unassigned.length===0&&k.jsx("div",{className:"text-center py-10",children:k.jsxs("p",{className:"text-sm text-slate-500 italic",children:['No entities found for "',r,'"']})})]})]}):null},$oe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,theme:n}=ci();return k.jsx("button",{onClick:()=>e(!t),className:`absolute -right-3.5 top-1/2 -translate-y-1/2 z-[60] flex h-7 w-7 items-center justify-center rounded-full border transition-all shadow-xl ${n==="dark"?"border-slate-700 bg-slate-900 text-slate-400 hover:text-white hover:bg-slate-800":"border-slate-200 bg-white text-slate-500 hover:text-blue-600 hover:bg-slate-50 shadow-slate-200/50"}`,"aria-label":t?"Collapse sidebar":"Expand sidebar",children:t?k.jsx(ZW,{size:16}):k.jsx(nS,{size:16})})},Goe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:n,isSidebarOpen:i,fetchAvailableFiles:r,theme:s}=ci(),[o,c]=j.useState(!1);if(!i||t.length<=0)return null;const u=async()=>{c(!0),await r(),setTimeout(()=>c(!1),500)},h=e||t[0]?.slug;return k.jsxs("div",{className:"px-4 mb-4",children:[k.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[k.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"}),k.jsx("button",{onClick:u,className:`transition-all p-0.5 rounded ${o?"animate-spin text-blue-400":"text-slate-500 hover:text-blue-400"} ${s==="dark"?"hover:bg-slate-800":"hover:bg-slate-100"}`,title:"Refresh model list",children:k.jsx(PK,{size:12})})]}),k.jsxs("div",{className:"relative group",children:[k.jsx("select",{value:h,onChange:d=>n(d.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${s==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(d=>k.jsx("option",{value:d.slug,className:s==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:d.name},d.slug))}),k.jsx(Go,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),k.jsx(tS,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${s==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Yoe=""+new URL("../favicon.svg",import.meta.url).href,Qoe=()=>{const{isSidebarOpen:t,activeTab:e,setActiveTab:n,isCliMode:i,theme:r,toggleTheme:s}=ci();return k.jsxs("div",{className:`relative h-full flex flex-col border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[400px]":"w-[50px]"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[k.jsx($oe,{}),k.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${!t&&"hidden"} ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("img",{src:Yoe,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),k.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"})]}),i&&k.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase",children:"Live"})]}),k.jsx("div",{className:"mt-4",children:t&&k.jsx(Goe,{})}),k.jsxs(RJ,{value:e,onValueChange:o=>n(o),className:`flex-1 flex flex-col overflow-hidden ${!t&&"items-center py-4"}`,children:[k.jsx("div",{className:`px-4 pt-4 ${!t&&"px-0"}`,children:k.jsxs(NB,{className:`w-full p-1 border ${r==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"} ${!t&&"flex-col h-auto w-10 gap-2 p-0 bg-transparent border-none"}`,children:[k.jsxs(oS,{value:"editor",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Editor",children:[k.jsx(LK,{size:14}),t&&k.jsx("span",{children:"Editor"})]}),k.jsxs(oS,{value:"entities",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Entities",children:[k.jsx(vK,{size:14}),t&&k.jsx("span",{children:"Entities"})]})]})}),t&&k.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[k.jsx(lS,{value:"editor",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Voe,{})}),k.jsx(lS,{value:"entities",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Foe,{})})]})]}),t&&k.jsxs("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:[k.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.0.8"}),k.jsx("button",{onClick:s,className:`p-1.5 rounded-lg transition-all ${r==="dark"?"text-slate-400 hover:bg-slate-800 hover:text-yellow-400":"text-slate-500 hover:bg-slate-200 hover:text-blue-600"}`,title:`Switch to ${r==="dark"?"Light":"Dark"} Mode`,children:r==="dark"?k.jsx(GK,{size:14}):k.jsx(AK,{size:14})})]})]})},Xoe=()=>{const{addTable:t,addDomain:e,getSelectedTable:n,getSelectedDomain:i,getSelectedRelationship:r,removeNode:s,removeEdge:o,showER:c,showLineage:u,setShowER:h,setShowLineage:d,setSelectedTableId:m,setSelectedEdgeId:g,calculateAutoLayout:y,theme:x}=ci(),{screenToFlowPosition:w}=Du(),[S,C]=j.useState(!1),A=c&&u,O=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});e(P.x-300,P.y-200)},E=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});t(P.x-160,P.y-125)},T=n(),M=i(),R=r(),z=T||M||R,q=()=>{T?s(T.id):M?s(M.id):R&&o(R.relationship.from.table,R.relationship.to.table)},U=()=>{m(null),g(null)};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"absolute top-4 left-4 z-10 flex flex-col gap-2",children:[k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl overflow-hidden w-14 transition-colors ${x==="dark"?"bg-slate-900/85 backdrop-blur-md border-slate-700":"bg-white/90 backdrop-blur-md border-slate-200"}`,children:[k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(lK,{size:12}),k.jsx("span",{children:"View"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsx("button",{onClick:()=>h(!c),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${c?"bg-emerald-500/20 text-emerald-500 border border-emerald-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:c?"Hide ER Relationships":"Show ER Relationships (Disables editing if Lineage is also ON)",children:k.jsx(RK,{size:20})}),k.jsx("button",{onClick:()=>d(!u),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${u?"bg-blue-500/20 text-blue-500 border border-blue-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:u?"Hide Data Lineage":"Show Data Lineage (Disables editing if ER is also ON)",children:k.jsx(g3,{size:20})})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(rS,{size:12}),k.jsx("span",{children:"Add"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsxs("button",{onClick:O,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-50"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Domain",children:[k.jsx(v3,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]}),k.jsxs("button",{onClick:E,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-emerald-400 hover:bg-slate-800":"text-slate-400 hover:text-emerald-600 hover:bg-slate-100"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Table",children:[k.jsx(fK,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(y3,{size:12}),k.jsx("span",{children:"Format"})]}),k.jsx("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:k.jsx("button",{onClick:()=>y(),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group ${x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-100"}`,title:"Auto-format Layout (Relation-driven flow)",children:k.jsx(y3,{size:20})})})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsx("div",{className:"flex flex-col items-center py-3",children:k.jsx("button",{onClick:()=>C(!S),className:`flex items-center justify-center w-10 h-10 rounded-xl transition-all ${S?x==="dark"?"bg-blue-600 text-white":"bg-blue-600 text-white shadow-md shadow-blue-500/20":x==="dark"?"text-slate-500 hover:bg-slate-800 hover:text-slate-300":"text-slate-400 hover:bg-slate-100 hover:text-slate-600"}`,title:"Keyboard Shortcuts & Help",children:k.jsx(F8,{size:20})})})]}),S&&k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl p-5 w-64 animate-in zoom-in-95 fade-in duration-200 origin-top-left ${x==="dark"?"bg-slate-900/95 backdrop-blur-xl border-slate-700":"bg-white/95 backdrop-blur-xl border-slate-200"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 mb-4 border-b pb-3 ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsx(sK,{size:16,className:"text-blue-500"}),k.jsx("h4",{className:`text-xs font-bold uppercase tracking-widest ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:"Shortcuts"})]}),k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Y8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Undo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Z"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx($8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Redo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Y"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Md,{size:14}),k.jsx("span",{className:"text-xs font-medium text-red-500/80",children:"Delete"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300 text-red-400/80":"bg-slate-50 border-slate-200 text-red-600/80"}`,children:"Del"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Yo,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Clear Focus"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Esc"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(TK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Pan Canvas"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Arrow Keys"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(OK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Multi-select"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Shift + Drag"})]})]}),k.jsx("div",{className:`mt-5 pt-3 border-t text-[10px] text-slate-400 italic leading-relaxed ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:"* Edits are saved to local YAML files in real-time if Auto-save is enabled."})]})]}),z&&k.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${x==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${x==="dark"?"border-slate-700":"border-slate-100"}`,children:[T&&k.jsx(Go,{size:16,className:"text-emerald-500"}),M&&k.jsx(v3,{size:16,className:"text-blue-500"}),R&&(R.relationship.type==="lineage"?k.jsx(g3,{size:16,className:"text-blue-400"}):k.jsx(G8,{size:16,className:"text-amber-500"})),k.jsxs("div",{className:"flex flex-col leading-tight",children:[k.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:["Selected ",T?"Table":M?"Domain":R?.relationship.type==="lineage"?"Lineage":"Relation"]}),k.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:T?T.name:M?M.name:R?`${R.relationship.from.table} → ${R.relationship.to.table}`:""})]})]}),k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsx("button",{onClick:q,className:"flex items-center justify-center w-8 h-8 hover:bg-red-500/20 text-slate-400 hover:text-red-500 rounded-lg transition-all group",title:"Delete Selected (Del)",children:k.jsx(Md,{size:16})}),k.jsx("button",{onClick:U,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection",children:k.jsx(Yo,{size:16})})]})]})]})},Woe=t=>{if(!t)return["",""];const n=t.toLowerCase().split("-to-");return n.length!==2?["",""]:n.map(i=>i.includes("one")?"1":i.includes("many")?"M":"")},E4=(t,e,n,i=45)=>{switch(n){case Te.Top:return{x:t,y:e-i};case Te.Bottom:return{x:t,y:e+i};case Te.Left:return{x:t-i,y:e};case Te.Right:return{x:t+i,y:e};default:return{x:t,y:e}}};function Koe({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r,targetPosition:s,style:o={},markerEnd:c,markerStart:u,label:h,data:d}){const[m]=Sd({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s}),{theme:g}=ci(),y=d?.isDirectlySelected,x=d?.isConnectedToSelectedTable,w=y||x,S=d?.label||h||"",[C,A]=Woe(S),O=E4(t,e,r),E=E4(n,i,s),T=({x:M,y:R,symbol:z})=>{if(!z)return null;const q=z==="1",U=`
|
|
52
52
|
absolute flex items-center justify-center
|
|
53
53
|
w-5 h-5 text-[9px] font-black border shadow-sm
|
|
54
54
|
backdrop-blur-sm transition-all duration-300
|