/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../state/dist/index.js"),t=require("../../view/dist/index.js"),n=require("../../language/dist/index.js"),r=require("../../../@lezer/common/dist/index.js"),o=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=c(e.state,n.from);return r.line?l(e):!!r.block&&a(e)};function s(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);return!!o&&(r(n.update(o)),!0)}}const l=s(d,0),i=s(f,0),a=s((e,t)=>f(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>r.from?t[s].to=o.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}(t)),0);function c(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const u=50;function f(e,t,n=t.selection.ranges){let r=n.map(e=>c(t,e.from).block);if(!r.every(e=>e))return null;let o=n.map((e,n)=>function(e,{open:t,close:n},r,o){let s,l,i=e.sliceDoc(r-u,r),a=e.sliceDoc(o,o+u),c=/\s*$/.exec(i)[0].length,f=/^\s*/.exec(a)[0].length,d=i.length-c;if(i.slice(d-t.length,d)==t&&a.slice(f,f+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+f,margin:f&&1}};o-r<=2*u?s=l=e.sliceDoc(r,o):(s=e.sliceDoc(r,r+u),l=e.sliceDoc(o-u,o));let h=/^\s*/.exec(s)[0].length,m=/\s*$/.exec(l)[0].length,p=l.length-m-n.length;return s.slice(h,h+t.length)==t&&l.slice(p,p+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(s.charAt(h+t.length))?1:0},close:{pos:o-m-n.length,margin:/\s/.test(l.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!o.every(e=>e))return{changes:t.changes(n.map((e,t)=>o[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&o.some(e=>e)){let e=[];for(let t,n=0;n<o.length;n++)if(t=o[n]){let o=r[n],{open:s,close:l}=t;e.push({from:s.pos-o.open.length,to:s.pos+s.margin},{from:l.pos-l.margin,to:l.pos+o.close.length})}return{changes:e}}return null}function d(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:s,to:l}of n){let e,n=r.length,i=1e9;for(let a=s;a<=l;){let n=t.doc.lineAt(a);if(null==e&&(e=c(t,n.from).line,!e))continue e;if(n.from>o&&(s==l||l>n.from)){o=n.from;let t=/^\s*/.exec(n.text)[0].length,s=t==n.length,l=n.text.slice(t,t+e.length)==e?t:-1;t<n.text.length&&t<i&&(i=t),r.push({line:n,comment:l,token:e,indent:t,empty:s,single:!1})}a=n.to+1}if(i<1e9)for(let t=n;t<r.length;t++)r[t].indent<r[t].line.text.length&&(r[t].indent=i);r.length==n+1&&(r[n].single=!0)}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:o,indent:s,empty:l,single:i}of r)!i&&l||e.push({from:t.from+s,insert:o+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:o}of r)if(n>=0){let r=t.from+n,s=r+o.length;" "==t.text[s-t.from]&&s++,e.push({from:r,to:s})}return{changes:e}}return null}const h=e.Annotation.define(),m=e.Annotation.define(),p=e.Facet.define(),g=e.Facet.define({combine:t=>e.combineConfig(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),y=e.StateField.define({create:()=>I.empty,update(t,n){let r=n.state.facet(g),o=n.annotation(h);if(o){let e=w.fromTransaction(n,o.selection),s=o.side,l=0==s?t.undone:t.done;return l=e?D(l,l.length,r.minDepth,e):M(l,n.startState.selection),new I(0==s?o.rest:l,0==s?l:o.rest)}let s=n.annotation(m);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===n.annotation(e.Transaction.addToHistory))return n.changes.empty?t:t.addMapping(n.changes.desc);let l=w.fromTransaction(n),i=n.annotation(e.Transaction.time),a=n.annotation(e.Transaction.userEvent);return l?t=t.addChanges(l,i,a,r,n):n.selection&&(t=t.addSelection(n.startState.selection,i,a,r.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new I(e.done.map(w.fromJSON),e.undone.map(w.fromJSON))});function x(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(y,!1);if(!o)return!1;let s=o.pop(e,n,t);return!!s&&(r(s),!0)}}const k=x(0,!1),v=x(1,!1),S=x(0,!0),A=x(1,!0);class w{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new w(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new w(t.changes&&e.ChangeSet.fromJSON(t.changes),[],t.mapped&&e.ChangeDesc.fromJSON(t.mapped),t.startSelection&&e.EditorSelection.fromJSON(t.startSelection),t.selectionsAfter.map(e.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=E;for(let r of e.startState.facet(p)){let t=r(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new w(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,E)}static selection(e){return new w(void 0,E,void 0,void 0,e)}}function D(e,t,n,r){let o=t+1>n+20?t-n-1:0,s=e.slice(o,t);return s.push(r),s}function B(e,t){return e.length?t.length?e.concat(t):e:t}const E=[],C=200;function M(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-C));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),D(e,e.length-1,1e9,n.setSelAfter(r)))}return[w.selection([t])]}function L(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function b(e,t){if(!e.length)return e;let n=e.length,r=E;for(;n;){let o=T(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let t=e.slice(0,n);return t[n-1]=o,t}t=o.mapped,n--,r=o.selectionsAfter}return r.length?[w.selection(r)]:E}function T(t,n,r){let o=B(t.selectionsAfter.length?t.selectionsAfter.map(e=>e.map(n)):E,r);if(!t.changes)return w.selection(o);let s=t.changes.map(n),l=n.mapDesc(t.changes,!0),i=t.mapped?t.mapped.composeDesc(l):l;return new w(s,e.StateEffect.mapEffects(t.effects,n),i,t.startSelection.map(l),o)}const O=/^(input\.type|delete)($|\.)/;class I{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new I(this.done,this.undone):this}addChanges(t,n,r,o,s){let l=this.done,i=l[l.length-1];return l=i&&i.changes&&!i.changes.empty&&t.changes&&(!r||O.test(r))&&(!i.selectionsAfter.length&&n-this.prevTime<o.newGroupDelay&&o.joinToEvent(s,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,o,s)=>{for(let l=0;l<n.length;){let e=n[l++],t=n[l++];s>=e&&o<=t&&(r=!0)}}),r}(i.changes,t.changes))||"input.type.compose"==r)?D(l,l.length-1,o.minDepth,new w(t.changes.compose(i.changes),B(e.StateEffect.mapEffects(t.effects,i.changes),i.effects),i.mapped,i.startSelection,E)):D(l,l.length,o.minDepth,t),new I(l,E,n,r)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:E;return o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(s=o[o.length-1],l=e,s.ranges.length==l.ranges.length&&0===s.ranges.filter((e,t)=>e.empty!=l.ranges[t].empty).length)?this:new I(M(this.done,e),this.undone,t,n);var s,l}addMapping(e){return new I(b(this.done,e),b(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let o=r[r.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:h.of({side:e,rest:L(r),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let n=1==r.length?E:r.slice(0,r.length-1);return o.mapped&&(n=b(n,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:h.of({side:e,rest:n,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}I.empty=new I(E,E);const R=[{key:"Mod-z",run:k,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:v,preventDefault:!0},{linux:"Ctrl-Shift-z",run:v,preventDefault:!0},{key:"Mod-u",run:S,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:A,preventDefault:!0}];function V(t,n){return e.EditorSelection.create(t.ranges.map(n),t.mainIndex)}function U(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function N({state:e,dispatch:t},n){let r=V(e.selection,n);return!r.eq(e.selection,!0)&&(t(U(e,r)),!0)}function J(t,n){return e.EditorSelection.cursor(n?t.to:t.from)}function P(e,t){return N(e,n=>n.empty?e.moveByChar(n,t):J(n,t))}function G(e){return e.textDirectionAt(e.state.selection.main.head)==t.Direction.LTR}const H=e=>P(e,!G(e)),F=e=>P(e,G(e));function j(e,t){return N(e,n=>n.empty?e.moveByGroup(n,t):J(n,t))}const q=e=>j(e,!G(e)),z=e=>j(e,G(e));function K(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function $(t,o,s){let l,i,a=n.syntaxTree(t).resolveInner(o.head),c=s?r.NodeProp.closedBy:r.NodeProp.openedBy;for(let e=o.head;;){let n=s?a.childAfter(e):a.childBefore(e);if(!n)break;K(t,n,c)?a=n:e=s?n.to:n.from}return i=a.type.prop(c)&&(l=s?n.matchBrackets(t,a.from,1):n.matchBrackets(t,a.to,-1))&&l.matched?s?l.end.to:l.end.from:s?a.to:a.from,e.EditorSelection.cursor(i,s?-1:1)}const W=e=>N(e,t=>$(e.state,t,!G(e))),Q=e=>N(e,t=>$(e.state,t,G(e)));function X(e,t){return N(e,n=>{if(!n.empty)return J(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Y=e=>X(e,!1),Z=e=>X(e,!0);function _(e){let n,r=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,o=0,s=0;if(r){for(let n of e.state.facet(t.EditorView.scrollMargins)){let t=n(e);(null==t?void 0:t.top)&&(o=Math.max(null==t?void 0:t.top,o)),(null==t?void 0:t.bottom)&&(s=Math.max(null==t?void 0:t.bottom,s))}n=e.scrollDOM.clientHeight-o-s}else n=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:o,marginBottom:s,selfScroll:r,height:Math.max(e.defaultLineHeight,n-5)}}function ee(e,n){let r,o=_(e),{state:s}=e,l=V(s.selection,t=>t.empty?e.moveVertically(t,n,o.height):J(t,n));if(l.eq(s.selection))return!1;if(o.selfScroll){let n=e.coordsAtPos(s.selection.main.head),i=e.scrollDOM.getBoundingClientRect(),a=i.top+o.marginTop,c=i.bottom-o.marginBottom;n&&n.top>a&&n.bottom<c&&(r=t.EditorView.scrollIntoView(l.main.head,{y:"start",yMargin:n.top-a}))}return e.dispatch(U(s,l),{effects:r}),!0}const te=e=>ee(e,!1),ne=e=>ee(e,!0);function re(t,n,r){let o=t.lineBlockAt(n.head),s=t.moveToLineBoundary(n,r);if(s.head==n.head&&s.head!=(r?o.to:o.from)&&(s=t.moveToLineBoundary(n,r,!1)),!r&&s.head==o.from&&o.length){let r=/^\s*/.exec(t.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;r&&n.head!=o.from+r&&(s=e.EditorSelection.cursor(o.from+r))}return s}const oe=e=>N(e,t=>re(e,t,!0)),se=e=>N(e,t=>re(e,t,!1)),le=e=>N(e,t=>re(e,t,!G(e))),ie=e=>N(e,t=>re(e,t,G(e))),ae=t=>N(t,n=>e.EditorSelection.cursor(t.lineBlockAt(n.head).from,1)),ce=t=>N(t,n=>e.EditorSelection.cursor(t.lineBlockAt(n.head).to,-1));const ue=({state:t,dispatch:r})=>function(t,r){let o=!1,s=V(t.selection,r=>{let s=n.matchBrackets(t,r.head,-1)||n.matchBrackets(t,r.head,1)||r.head>0&&n.matchBrackets(t,r.head-1,1)||r.head<t.doc.length&&n.matchBrackets(t,r.head+1,-1);if(!s||!s.end)return r;o=!0;let l=s.start.from==r.head?s.end.to:s.end.from;return e.EditorSelection.cursor(l)});return!!o&&(r(U(t,s)),!0)}(t,r);function fe(t,n){let r=V(t.state.selection,t=>{let r=n(t);return e.EditorSelection.range(t.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return!r.eq(t.state.selection)&&(t.dispatch(U(t.state,r)),!0)}function de(e,t){return fe(e,n=>e.moveByChar(n,t))}const he=e=>de(e,!G(e)),me=e=>de(e,G(e));function pe(e,t){return fe(e,n=>e.moveByGroup(n,t))}const ge=e=>pe(e,!G(e)),ye=e=>pe(e,G(e)),xe=e=>fe(e,t=>$(e.state,t,!G(e))),ke=e=>fe(e,t=>$(e.state,t,G(e)));function ve(e,t){return fe(e,n=>e.moveVertically(n,t))}const Se=e=>ve(e,!1),Ae=e=>ve(e,!0);function we(e,t){return fe(e,n=>e.moveVertically(n,t,_(e).height))}const De=e=>we(e,!1),Be=e=>we(e,!0),Ee=e=>fe(e,t=>re(e,t,!0)),Ce=e=>fe(e,t=>re(e,t,!1)),Me=e=>fe(e,t=>re(e,t,!G(e))),Le=e=>fe(e,t=>re(e,t,G(e))),be=t=>fe(t,n=>e.EditorSelection.cursor(t.lineBlockAt(n.head).from)),Te=t=>fe(t,n=>e.EditorSelection.cursor(t.lineBlockAt(n.head).to)),Oe=({state:e,dispatch:t})=>(t(U(e,{anchor:0})),!0),Ie=({state:e,dispatch:t})=>(t(U(e,{anchor:e.doc.length})),!0),Re=({state:e,dispatch:t})=>(t(U(e,{anchor:e.selection.main.anchor,head:0})),!0),Ve=({state:e,dispatch:t})=>(t(U(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ue=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Ne=({state:t,dispatch:n})=>{let r=nt(t).map(({from:n,to:r})=>e.EditorSelection.range(n,Math.min(r+1,t.doc.length)));return n(t.update({selection:e.EditorSelection.create(r),userEvent:"select"})),!0},Je=({state:t,dispatch:r})=>{let o=V(t.selection,r=>{let o=n.syntaxTree(t),s=o.resolveStack(r.from,1);if(r.empty){let e=o.resolveStack(r.from,-1);e.node.from>=s.node.from&&e.node.to<=s.node.to&&(s=e)}for(let t=s;t;t=t.next){let{node:n}=t;if((n.from<r.from&&n.to>=r.to||n.to>r.to&&n.from<=r.from)&&t.next)return e.EditorSelection.range(n.to,n.from)}return r});return!o.eq(t.selection)&&(r(U(t,o)),!0)};function Pe(t,n){let{state:r}=t,o=r.selection,s=r.selection.ranges.slice();for(let e of r.selection.ranges){let o=r.doc.lineAt(e.head);if(n?o.to<t.state.doc.length:o.from>0)for(let r=e;;){let e=t.moveVertically(r,n);if(e.head<o.from||e.head>o.to){s.some(t=>t.head==e.head)||s.push(e);break}if(e.head==r.head)break;r=e}}return s.length!=o.ranges.length&&(t.dispatch(U(r,e.EditorSelection.create(s,s.length-1))),!0)}const Ge=e=>Pe(e,!1),He=e=>Pe(e,!0),Fe=({state:t,dispatch:n})=>{let r=t.selection,o=null;return r.ranges.length>1?o=e.EditorSelection.create([r.main]):r.main.empty||(o=e.EditorSelection.create([e.EditorSelection.cursor(r.main.head)])),!!o&&(n(U(t,o)),!0)};function je(n,r){if(n.state.readOnly)return!1;let o="delete.selection",{state:s}=n,l=s.changeByRange(t=>{let{from:s,to:l}=t;if(s==l){let e=r(t);e<s?(o="delete.backward",e=qe(n,e,!1)):e>s&&(o="delete.forward",e=qe(n,e,!0)),s=Math.min(s,e),l=Math.max(l,e)}else s=qe(n,s,!1),l=qe(n,l,!0);return s==l?{range:t}:{changes:{from:s,to:l},range:e.EditorSelection.cursor(s,s<t.head?-1:1)}});return!l.changes.empty&&(n.dispatch(s.update(l,{scrollIntoView:!0,userEvent:o,effects:"delete.selection"==o?t.EditorView.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function qe(e,n,r){if(e instanceof t.EditorView)for(let o of e.state.facet(t.EditorView.atomicRanges).map(t=>t(e)))o.between(n,n,(e,t)=>{e<n&&t>n&&(n=r?t:e)});return n}const ze=(t,r,o)=>je(t,s=>{let l,i,a=s.from,{state:c}=t,u=c.doc.lineAt(a);if(o&&!r&&a>u.from&&a<u.from+200&&!/[^ \t]/.test(l=u.text.slice(0,a-u.from))){if("\t"==l[l.length-1])return a-1;let t=e.countColumn(l,c.tabSize)%n.getIndentUnit(c)||n.getIndentUnit(c);for(let e=0;e<t&&" "==l[l.length-1-e];e++)a--;i=a}else i=e.findClusterBreak(u.text,a-u.from,r,r)+u.from,i==a&&u.number!=(r?c.doc.lines:1)?i+=r?1:-1:!r&&/[\ufe00-\ufe0f]/.test(u.text.slice(i-u.from,a-u.from))&&(i=e.findClusterBreak(u.text,i-u.from,!1,!1)+u.from);return i}),Ke=e=>ze(e,!1,!0),$e=e=>ze(e,!0,!1),We=(t,n)=>je(t,r=>{let o=r.head,{state:s}=t,l=s.doc.lineAt(o),i=s.charCategorizer(o);for(let t=null;;){if(o==(n?l.to:l.from)){o==r.head&&l.number!=(n?s.doc.lines:1)&&(o+=n?1:-1);break}let a=e.findClusterBreak(l.text,o-l.from,n)+l.from,c=l.text.slice(Math.min(o,a)-l.from,Math.max(o,a)-l.from),u=i(c);if(null!=t&&u!=t)break;" "==c&&o==r.head||(t=u),o=a}return o}),Qe=e=>We(e,!1),Xe=e=>We(e,!0),Ye=e=>je(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Ze=e=>je(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),_e=e=>je(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),et=({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e.Text.of(["",""])},range:e.EditorSelection.cursor(t.from)}));return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},tt=({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||0==n.from||n.from==t.doc.length)return{range:n};let r=n.from,o=t.doc.lineAt(r),s=r==o.from?r-1:e.findClusterBreak(o.text,r-o.from,!1)+o.from,l=r==o.to?r+1:e.findClusterBreak(o.text,r-o.from,!0)+o.from;return{changes:{from:s,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(s,r))},range:e.EditorSelection.cursor(l)}});return!r.changes.empty&&(n(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function nt(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),s=e.doc.lineAt(r.to);if(r.empty||r.to!=s.from||(s=e.doc.lineAt(r.to-1)),n>=o.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(r)}else t.push({from:o.from,to:s.to,ranges:[r]});n=s.number+1}return t}function rt(t,n,r){if(t.readOnly)return!1;let o=[],s=[];for(let l of nt(t)){if(r?l.to==t.doc.length:0==l.from)continue;let n=t.doc.lineAt(r?l.to+1:l.from-1),i=n.length+1;if(r){o.push({from:l.to,to:n.to},{from:l.from,insert:n.text+t.lineBreak});for(let n of l.ranges)s.push(e.EditorSelection.range(Math.min(t.doc.length,n.anchor+i),Math.min(t.doc.length,n.head+i)))}else{o.push({from:n.from,to:l.from},{from:l.to,insert:t.lineBreak+n.text});for(let t of l.ranges)s.push(e.EditorSelection.range(t.anchor-i,t.head-i))}}return!!o.length&&(n(t.update({changes:o,scrollIntoView:!0,selection:e.EditorSelection.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}const ot=({state:e,dispatch:t})=>rt(e,t,!1),st=({state:e,dispatch:t})=>rt(e,t,!0);function lt(e,t,n){if(e.readOnly)return!1;let r=[];for(let s of nt(e))n?r.push({from:s.from,insert:e.doc.slice(s.from,s.to)+e.lineBreak}):r.push({from:s.to,insert:e.lineBreak+e.doc.slice(s.from,s.to)});let o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const it=({state:e,dispatch:t})=>lt(e,t,!1),at=({state:e,dispatch:t})=>lt(e,t,!0),ct=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(nt(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=V(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),o=e.coordsAtPos(t.head,t.assoc||1);o&&(n=r.bottom+e.documentTop-o.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};const ut=dt(!1),ft=dt(!0);function dt(t){return({state:o,dispatch:s})=>{if(o.readOnly)return!1;let l=o.changeByRange(s=>{let{from:l,to:i}=s,a=o.doc.lineAt(l),c=!t&&l==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let o,s=n.syntaxTree(e).resolveInner(t),l=s.childBefore(t),i=s.childAfter(t);return l&&i&&l.to<=t&&i.from>=t&&(o=l.type.prop(r.NodeProp.closedBy))&&o.indexOf(i.name)>-1&&e.doc.lineAt(l.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(l.to,i.from))?{from:l.to,to:i.from}:null}(o,l);t&&(l=i=(i<=a.to?a:o.doc.lineAt(i)).to);let u=new n.IndentContext(o,{simulateBreak:l,simulateDoubleBreak:!!c}),f=n.getIndentation(u,l);for(null==f&&(f=e.countColumn(/^\s*/.exec(o.doc.lineAt(l).text)[0],o.tabSize));i<a.to&&/\s/.test(a.text[i-a.from]);)i++;c?({from:l,to:i}=c):l>a.from&&l<a.from+100&&!/\S/.test(a.text.slice(0,l))&&(l=a.from);let d=["",n.indentString(o,f)];return c&&d.push(n.indentString(o,u.lineIndent(a.from,-1))),{changes:{from:l,to:i,insert:e.Text.of(d)},range:e.EditorSelection.cursor(l+1+d[1].length)}});return s(o.update(l,{scrollIntoView:!0,userEvent:"input"})),!0}}function ht(t,n){let r=-1;return t.changeByRange(o=>{let s=[];for(let e=o.from;e<=o.to;){let l=t.doc.lineAt(e);l.number>r&&(o.empty||o.to>l.from)&&(n(l,s,o),r=l.number),e=l.to+1}let l=t.changes(s);return{changes:s,range:e.EditorSelection.range(l.mapPos(o.anchor,1),l.mapPos(o.head,1))}})}const mt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),o=new n.IndentContext(e,{overrideIndentation:e=>{let t=r[e];return null==t?-1:t}}),s=ht(e,(t,s,l)=>{let i=n.getIndentation(o,t.from);if(null==i)return;/\S/.test(t.text)||(i=0);let a=/^\s*/.exec(t.text)[0],c=n.indentString(e,i);(a!=c||l.from<t.from+a.length)&&(r[t.from]=i,s.push({from:t.from,to:t.from+a.length,insert:c}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0},pt=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ht(e,(t,r)=>{r.push({from:t.from,insert:e.facet(n.indentUnit)})}),{userEvent:"input.indent"})),!0),gt=({state:t,dispatch:r})=>!t.readOnly&&(r(t.update(ht(t,(r,o)=>{let s=/^\s*/.exec(r.text)[0];if(!s)return;let l=e.countColumn(s,t.tabSize),i=0,a=n.indentString(t,Math.max(0,l-n.getIndentUnit(t)));for(;i<s.length&&i<a.length&&s.charCodeAt(i)==a.charCodeAt(i);)i++;o.push({from:r.from+i,to:r.from+s.length,insert:a.slice(i)})}),{userEvent:"delete.dedent"})),!0),yt=e=>(e.setTabFocusMode(),!0),xt=[{key:"Ctrl-b",run:H,shift:he,preventDefault:!0},{key:"Ctrl-f",run:F,shift:me},{key:"Ctrl-p",run:Y,shift:Se},{key:"Ctrl-n",run:Z,shift:Ae},{key:"Ctrl-a",run:ae,shift:be},{key:"Ctrl-e",run:ce,shift:Te},{key:"Ctrl-d",run:$e},{key:"Ctrl-h",run:Ke},{key:"Ctrl-k",run:Ye},{key:"Ctrl-Alt-h",run:Qe},{key:"Ctrl-o",run:et},{key:"Ctrl-t",run:tt},{key:"Ctrl-v",run:ne}],kt=[{key:"ArrowLeft",run:H,shift:he,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:q,shift:ge,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:le,shift:Me,preventDefault:!0},{key:"ArrowRight",run:F,shift:me,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:z,shift:ye,preventDefault:!0},{mac:"Cmd-ArrowRight",run:ie,shift:Le,preventDefault:!0},{key:"ArrowUp",run:Y,shift:Se,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Oe,shift:Re},{mac:"Ctrl-ArrowUp",run:te,shift:De},{key:"ArrowDown",run:Z,shift:Ae,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ie,shift:Ve},{mac:"Ctrl-ArrowDown",run:ne,shift:Be},{key:"PageUp",run:te,shift:De},{key:"PageDown",run:ne,shift:Be},{key:"Home",run:se,shift:Ce,preventDefault:!0},{key:"Mod-Home",run:Oe,shift:Re},{key:"End",run:oe,shift:Ee,preventDefault:!0},{key:"Mod-End",run:Ie,shift:Ve},{key:"Enter",run:ut,shift:ut},{key:"Mod-a",run:Ue},{key:"Backspace",run:Ke,shift:Ke,preventDefault:!0},{key:"Delete",run:$e,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Qe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Xe,preventDefault:!0},{mac:"Mod-Backspace",run:Ze,preventDefault:!0},{mac:"Mod-Delete",run:_e,preventDefault:!0}].concat(xt.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),vt=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:W,shift:xe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Q,shift:ke},{key:"Alt-ArrowUp",run:ot},{key:"Shift-Alt-ArrowUp",run:it},{key:"Alt-ArrowDown",run:st},{key:"Shift-Alt-ArrowDown",run:at},{key:"Mod-Alt-ArrowUp",run:Ge},{key:"Mod-Alt-ArrowDown",run:He},{key:"Escape",run:Fe},{key:"Mod-Enter",run:ft},{key:"Alt-l",mac:"Ctrl-l",run:Ne},{key:"Mod-i",run:Je,preventDefault:!0},{key:"Mod-[",run:gt},{key:"Mod-]",run:pt},{key:"Mod-Alt-\\",run:mt},{key:"Shift-Mod-k",run:ct},{key:"Shift-Mod-\\",run:ue},{key:"Mod-/",run:o},{key:"Alt-A",run:i},{key:"Ctrl-m",mac:"Shift-Alt-m",run:yt}].concat(kt),St={key:"Tab",run:pt,shift:gt};exports.addCursorAbove=Ge,exports.addCursorBelow=He,exports.copyLineDown=at,exports.copyLineUp=it,exports.cursorCharLeft=H,exports.cursorCharRight=F,exports.cursorDocEnd=Ie,exports.cursorDocStart=Oe,exports.cursorGroupLeft=q,exports.cursorGroupRight=z,exports.cursorLineBoundaryBackward=se,exports.cursorLineBoundaryForward=oe,exports.cursorLineBoundaryLeft=le,exports.cursorLineBoundaryRight=ie,exports.cursorLineDown=Z,exports.cursorLineEnd=ce,exports.cursorLineStart=ae,exports.cursorLineUp=Y,exports.cursorMatchingBracket=ue,exports.cursorPageDown=ne,exports.cursorPageUp=te,exports.cursorSyntaxLeft=W,exports.cursorSyntaxRight=Q,exports.defaultKeymap=vt,exports.deleteCharBackward=Ke,exports.deleteCharForward=$e,exports.deleteGroupBackward=Qe,exports.deleteGroupForward=Xe,exports.deleteLine=ct,exports.deleteLineBoundaryBackward=Ze,exports.deleteLineBoundaryForward=_e,exports.deleteToLineEnd=Ye,exports.emacsStyleKeymap=xt,exports.history=function(e={}){return[y,g.of(e),t.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?k:"historyRedo"==e.inputType?v:null;return!!n&&(e.preventDefault(),n(t))}})]},exports.historyKeymap=R,exports.indentLess=gt,exports.indentMore=pt,exports.indentSelection=mt,exports.indentWithTab=St,exports.insertBlankLine=ft,exports.insertNewlineAndIndent=ut,exports.invertedEffects=p,exports.isolateHistory=m,exports.moveLineDown=st,exports.moveLineUp=ot,exports.redo=v,exports.redoSelection=A,exports.selectAll=Ue,exports.selectCharLeft=he,exports.selectCharRight=me,exports.selectDocEnd=Ve,exports.selectDocStart=Re,exports.selectGroupLeft=ge,exports.selectGroupRight=ye,exports.selectLine=Ne,exports.selectLineBoundaryBackward=Ce,exports.selectLineBoundaryForward=Ee,exports.selectLineBoundaryLeft=Me,exports.selectLineBoundaryRight=Le,exports.selectLineDown=Ae,exports.selectLineEnd=Te,exports.selectLineStart=be,exports.selectLineUp=Se,exports.selectPageDown=Be,exports.selectPageUp=De,exports.selectParentSyntax=Je,exports.selectSyntaxLeft=xe,exports.selectSyntaxRight=ke,exports.simplifySelection=Fe,exports.splitLine=et,exports.standardKeymap=kt,exports.toggleBlockComment=i,exports.toggleBlockCommentByLine=a,exports.toggleComment=o,exports.toggleLineComment=l,exports.toggleTabFocusMode=yt,exports.transposeChars=tt,exports.undo=k,exports.undoSelection=S;