"use strict";const Y=require("@codemirror/view"),ee=require("@codemirror/state"),Re=require("@codemirror/language"),Je=require("@codemirror/search"),Le=require("@codemirror/commands"),er=require("markedit-api");function sn(u){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const c in u)if(c!=="default"){const p=Object.getOwnPropertyDescriptor(u,c);Object.defineProperty(a,c,p.get?p:{enumerable:!0,get:()=>u[c]})}}return a.default=u,Object.freeze(a)}const ln=sn(Y);function un(u){var a=u.Pos;function c(e,t,r){if(t.line===r.line&&t.ch>=r.ch-1){var n=e.getLine(t.line),i=n.charCodeAt(t.ch);55296<=i&&i<=55551&&(r.ch+=1)}return{start:t,end:r}}var p=[{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"g",type:"keyToKey",toKeys:"gk"},{keys:"g",type:"keyToKey",toKeys:"gj"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"x"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"idle",context:"normal"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],y=Object.create(null),k=p.length,b=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],x=Ct("");function L(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),u.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",Ut),De(e),u.on(e.getInputField(),"paste",D(e))}function F(e){e.setOption("disableInput",!1),e.off("cursorActivity",Ut),u.off(e.getInputField(),"paste",D(e)),e.state.vim=null,ze&&clearTimeout(ze)}function D(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(G(e.getCursor(),0,1)),He.enterInsertMode(e,{},t))}),t.onPasteFn}var H=/[\d]/,j=[u.isWordChar,function(e){return e&&!u.isWordChar(e)&&!/\s/.test(e)}],B=[function(e){return/\S/.test(e)}],_=["<",">"],Q=["-",'"',".",":","_","/","+"],W=/^\w$/,J=/^[A-Z]$/;try{J=new RegExp("^[\\p{Lu}]$","u")}catch{}function ae(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function se(e){return/^[a-z]$/.test(e)}function de(e){return"()[]{}".indexOf(e)!=-1}function le(e){return H.test(e)}function me(e){return J.test(e)}function te(e){return/^\s*$/.test(e)}function Pe(e){return".?!".indexOf(e)!=-1}function tt(e,t){for(var r=0;r1&&t.setOption("textwidth",n)}});var ur=function(){var e=100,t=-1,r=0,n=0,i=new Array(e);function o(f,d,h){var g=t%e,m=i[g];function C(w){var S=++t%e,T=i[S];T&&T.clear(),i[S]=f.setBookmark(w)}if(m){var v=m.find();v&&!pe(v,d)&&C(d)}else C(d);C(h),r=t,n=t-e+1,n<0&&(n=0)}function s(f,d){t+=d,t>r?t=r:t0?1:-1,m,C=f.getCursor();do if(t+=g,h=i[(e+t)%e],h&&(m=h.find())&&!pe(C,m))break;while(tn)}return h}function l(f,d){var h=t,g=s(f,d);return t=h,g&&g.find()}return{cachedCursor:void 0,add:o,find:l,move:s}},gt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class fr{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=gt()}exitMacroRecordMode(){var t=E.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,r){var n=E.registerController.getRegister(r);if(n){if(n.clear(),this.latestRegister=r,t.openDialog){var i=ke("span",{class:"cm-vim-message"},"recording @"+r);this.onRecordingDone=t.openDialog(i,function(){},{bottom:!0})}this.isRecording=!0}}}function De(e){return e.state.vim||(e.state.vim={inputState:new kt,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new a(0,0),head:new a(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var E;function yt(){E={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:ur(),macroModeState:new fr,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new vr({}),searchHistoryController:new wt,exCommandHistoryController:new wt};for(var e in Ee){var t=Ee[e];t.value=t.defaultValue}}class rt{constructor(t,r){this.keyName=t,this.key=r.key,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.metaKey=r.metaKey,this.shiftKey=r.shiftKey}}var We,ce={enterVimMode:L,leaveVimMode:F,buildKeyMap:function(){},getRegisterController:function(){return E.registerController},resetVimGlobalState_:yt,getVimGlobalState_:function(){return E},maybeInitVimState_:De,suppressErrorLogging:!1,InsertModeKey:rt,map:function(e,t,r){ue.map(e,t,r)},unmap:function(e,t){return ue.unmap(e,t)},noremap:function(e,t,r){ue.map(e,t,r,!0)},mapclear:function(e){var t=p.length,r=k,n=p.slice(0,t-r);if(p=p.slice(t-r),e)for(var i=n.length-1;i>=0;i--){var o=n[i];if(e!==o.context)if(o.context)this._mapCommand(o);else{var s=["normal","insert","visual"];for(var l in s)if(s[l]!==e){var f=Object.assign({},o);f.context=s[l],this._mapCommand(f)}}}},langmap:mt,vimKeyFromEvent:Ue,setOption:Xe,getOption:fe,defineOption:Ke,defineEx:function(e,t,r){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');Wt[e]=r,ue.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if(typeof n=="function")return n()},multiSelectHandleKey:on,findKey:function(e,t,r){var n=De(e),i=e;function o(){var h=E.macroModeState;if(h.isRecording){if(t=="q")return h.exitMacroRecordMode(),Z(i),!0;r!="mapping"&&tn(h,t)}}function s(){if(t==""){if(n.visualMode)xe(i);else if(n.insertMode)Oe(i);else return;return Z(i),!0}}function l(){if(s())return!0;n.inputState.keyBuffer.push(t);var h=n.inputState.keyBuffer.join(""),g=t.length==1,m=Ie.matchCommand(h,p,n.inputState,"insert"),C=n.inputState.changeQueue;if(m.type=="none")return Z(i),!1;if(m.type=="partial"){if(m.expectLiteralNext&&(n.expectLiteralNext=!0),We&&window.clearTimeout(We),We=g&&window.setTimeout(function(){n.insertMode&&n.inputState.keyBuffer.length&&Z(i)},fe("insertModeEscKeysTimeout")),g){var v=i.listSelections();(!C||C.removed.length!=v.length)&&(C=n.inputState.changeQueue=new dr),C.inserted+=t;for(var w=0;w/.test(t))?function(){return!0}:void 0;if(d===!0)return function(){return!0};if(d)return function(){return i.operation(function(){i.curOp.isVimOp=!0;try{if(typeof d!="object")return;d.type=="keyToKey"?je(i,d.toKeys,d):Ie.processCommand(i,n,d)}catch(h){throw i.state.vim=void 0,De(i),ce.suppressErrorLogging||console.log(h),h}return!0})}},handleEx:function(e,t){ue.processCommand(e,t)},defineMotion:gr,defineAction:mr,defineOperator:yr,mapCommand:Zr,_mapCommand:ct,defineRegister:pr,exitVisualMode:xe,exitInsertMode:Oe},_e=[],Ge=!1,X;function cr(e){if(!X)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),r=t.split("-");if(t=r.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=` `;else if(Fe[t]){var n=X.value||"",i={key:Fe[t],target:{value:n,selectionEnd:n.length,selectionStart:n.length}};X.onKeyDown&&X.onKeyDown(i,X.value,s),X&&X.onKeyUp&&X.onKeyUp(i,X.value,s);return}}if(e==` `){var o=X;X=null,o.onClose&&o.onClose(o.value)}else X.value=(X.value||"")+e;function s(l){X&&(typeof l=="string"?X.value=l:X=null)}}function je(e,t,r){var n=Ge;if(r){if(_e.indexOf(r)!=-1)return;_e.push(r),Ge=r.noremap!=!1}try{for(var i=De(e),o=/<(?:[CSMA]-)*\w+>|./gi,s;s=o.exec(t);){var l=s[0],f=i.insertMode;if(X){cr(l);continue}var d=ce.handleKey(e,l,"mapping");if(!d&&f&&i.insertMode){if(l[0]=="<"){var h=l.toLowerCase().slice(1,-1),g=h.split("-");if(h=g.pop()||"",h=="lt")l="<";else if(h=="space")l=" ";else if(h=="cr")l=` `;else if(Fe.hasOwnProperty(h)){l=Fe[h],qt(e,l);continue}else l=l[0],o.lastIndex=s.index+1}e.replaceSelection(l)}}}finally{if(_e.pop(),Ge=_e.length?n:!1,!_e.length&&X){var m=X;X=null,Ze(e,m)}}}var nt={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},hr={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Fe={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(nt)).forEach(function(e){Fe[(nt[e]||"").toLowerCase()]=Fe[e.toLowerCase()]=e});function Ue(e,t){var r=e.key;if(!hr[r]){r.length>1&&r[0]=="n"&&(r=r.replace("Numpad","")),r=nt[r]||r;var n="";if(e.ctrlKey&&(n+="C-"),e.altKey&&(n+="A-"),e.metaKey&&(n+="M-"),u.isMac&&n=="A-"&&r.length==1&&(n=n.slice(2)),(n||r.length>1)&&e.shiftKey&&(n+="S-"),t&&!t.expectLiteralNext&&r.length==1){if(x.keymap&&r in x.keymap)(x.remapCtrl!=!1||!n)&&(r=x.keymap[r]);else if(r.charCodeAt(0)>128&&!y[r]){var i=e.code?.slice(-1)||"";e.shiftKey||(i=i.toLowerCase()),i&&(r=i,!n&&e.altKey&&(n="A-"))}}return n+=r,n.length>1&&(n="<"+n+">"),n}}function mt(e,t){x.string!==e&&(x=Ct(e)),x.remapCtrl=t}function Ct(e){let t={};if(!e)return{keymap:t,string:""};function r(n){return n.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(n=>{if(!n)return;const i=n.split(/((?:[^\\;]|\\.)+);/);if(i.length==3){const o=r(i[1]),s=r(i[2]);if(o.length!==s.length)return;for(let l=0;l0||this.motionRepeat.length>0)&&(t=1,this.prefixRepeat.length>0&&(t*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(t*=parseInt(this.motionRepeat.join(""),10))),t}}function Z(e,t){e.state.vim.inputState=new kt,e.state.vim.expectLiteralNext=!1,u.signal(e,"vim-command-done",t)}function dr(){this.removed=[],this.inserted=""}class we{constructor(t,r,n){this.clear(),this.keyBuffer=[t||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!r,this.blockwise=!!n}setText(t,r,n){this.keyBuffer=[t||""],this.linewise=!!r,this.blockwise=!!n}pushText(t,r){r&&(this.linewise||this.keyBuffer.push(` `),this.linewise=!0),this.keyBuffer.push(t)}pushInsertModeChanges(t){this.insertModeChanges.push(gt(t))}pushSearchQuery(t){this.searchQueries.push(t)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function pr(e,t){var r=E.registerController.registers;if(!e||e.length!=1)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,Q.push(e)}class vr{constructor(t){this.registers=t,this.unnamedRegister=t['"']=new we,t["."]=new we,t[":"]=new we,t["/"]=new we,t["+"]=new we}pushText(t,r,n,i,o){if(t!=="_"){i&&n.charAt(n.length-1)!==` `&&(n+=` `);var s=this.isValidRegister(t)?this.getRegister(t):null;if(!s||!t){switch(r){case"yank":this.registers[0]=new we(n,i,o);break;case"delete":case"change":n.indexOf(` `)==-1?this.registers["-"]=new we(n,i):(this.shiftNumericRegisters_(),this.registers[1]=new we(n,i));break}this.unnamedRegister.setText(n,i,o);return}var l=me(t);l?s.pushText(n,i):s.setText(n,i,o),t==="+"&&navigator.clipboard.writeText(n),this.unnamedRegister.setText(s.toString(),i)}}getRegister(t){return this.isValidRegister(t)?(t=t.toLowerCase(),this.registers[t]||(this.registers[t]=new we),this.registers[t]):this.unnamedRegister}isValidRegister(t){return t&&(tt(t,Q)||W.test(t))}shiftNumericRegisters_(){for(var t=9;t>=2;t--)this.registers[t]=this.getRegister(""+(t-1))}}class wt{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(t,r){var n=this.historyBuffer,i=r?-1:1;this.initialPrefix===null&&(this.initialPrefix=t);for(var o=this.iterator+i;r?o>=0:o=n.length)return this.iterator=n.length,this.initialPrefix;if(o<0)return t}pushInput(t){var r=this.historyBuffer.indexOf(t);r>-1&&this.historyBuffer.splice(r,1),t.length&&this.historyBuffer.push(t)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var Ie={matchCommand:function(e,t,r,n){var i=Cr(e,t,n,r),o=i.full[0];if(!o)return i.partial.length?{type:"partial",expectLiteralNext:i.partial.length==1&&i.partial[0].keys.slice(-11)==""}:{type:"none"};if(o.keys.slice(-11)==""||o.keys.slice(-10)==""){var s=wr(e);if(!s||s.length>1)return{type:"clear"};r.selectedCharacter=s}return{type:"full",command:o}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r);break}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=Ye(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator)if(n.operator==r.operator){n.motion="expandToLine",n.motionArgs={linewise:!0,repeat:1},this.evalInput(e,t);return}else Z(e);n.operator=r.operator,n.operatorArgs=Ye(r.operatorArgs),r.keys.length>1&&(n.operatorShortcut=r.keys),r.exitVisualBlock&&(t.visualBlock=!1,Ve(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,i=Ye(r.operatorMotionArgs);i&&n&&i.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,i=n.getRepeat(),o=!!i,s=Ye(r.actionArgs)||{repeat:1};n.selectedCharacter&&(s.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),s.repeat=i||1,s.repeatIsExplicit=o,s.registerName=n.registerName,Z(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),He[r.action](e,s,t)},processSearch:function(e,t,r){if(!e.getSearchCursor)return;var n=r.searchArgs.forward,i=r.searchArgs.wholeWordOnly;Ce(e).setReversed(!n);var o=n?"/":"?",s=Ce(e).getQuery(),l=e.getScrollInfo(),f="";function d(M,O,N){E.searchHistoryController.pushInput(M),E.searchHistoryController.reset();try{Qe(e,M,O,N)}catch{K(e,"Invalid regex: "+M),Z(e);return}Ie.processMotion(e,t,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:r.searchArgs.toJumplist}})}function h(M){e.scrollTo(l.left,l.top),d(M,!0,!0);var O=E.macroModeState;O.isRecording&&nn(O,M)}function g(){return fe("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function m(M,O,N){var R=Ue(M),U,z;R==""||R==""?(U=R=="",z=M.target?M.target.selectionEnd:0,O=E.searchHistoryController.nextMatch(O,U)||"",N(O),z&&M.target&&(M.target.selectionEnd=M.target.selectionStart=Math.min(z,M.target.value.length))):R&&R!=""&&R!=""&&E.searchHistoryController.reset(),f=O,C()}function C(){var M;try{M=Qe(e,f,!0,!0)}catch{}M?e.scrollIntoView(Vt(e,!n,M),30):($e(e),e.scrollTo(l.left,l.top))}function v(M,O,N){var R=Ue(M);R==""||R==""||R==""||R==""&&O==""?(E.searchHistoryController.pushInput(O),E.searchHistoryController.reset(),Qe(e,s?.source||""),$e(e),e.scrollTo(l.left,l.top),u.e_stop(M),Z(e),N(),e.focus()):R==""||R==""?u.e_stop(M):R==""&&(u.e_stop(M),N(""))}switch(r.searchArgs.querySrc){case"prompt":var w=E.macroModeState;if(w.isPlaying){let O=w.replaySearchQueries.shift();d(O||"",!0,!1)}else Ze(e,{onClose:h,prefix:o,desc:ke("span",{$cursor:"pointer",onmousedown:function(O){O.preventDefault(),Xe("pcre",!fe("pcre")),this.textContent=g(),C()}},g()),onKeyUp:m,onKeyDown:v});break;case"wordUnderCursor":var S=st(e,{noSymbol:!0}),T=!0;if(S||(S=st(e,{noSymbol:!1}),T=!1),!S){K(e,"No word under cursor"),Z(e);return}let M=e.getLine(S.start.line).substring(S.start.ch,S.end.ch);T&&i?M="\\b"+M+"\\b":M=Sr(M),E.jumpList.cachedCursor=e.getCursor(),e.setCursor(S.start),d(M,!0,!1);break}},processEx:function(e,t,r){function n(l){E.exCommandHistoryController.pushInput(l),E.exCommandHistoryController.reset(),ue.processCommand(e,l),e.state.vim&&Z(e),$e(e)}function i(l,f,d){var h=Ue(l),g,m;(h==""||h==""||h==""||h==""&&f=="")&&(E.exCommandHistoryController.pushInput(f),E.exCommandHistoryController.reset(),u.e_stop(l),Z(e),$e(e),d(),e.focus()),h==""||h==""?(u.e_stop(l),g=h=="",m=l.target?l.target.selectionEnd:0,f=E.exCommandHistoryController.nextMatch(f,g)||"",d(f),m&&l.target&&(l.target.selectionEnd=l.target.selectionStart=Math.min(m,l.target.value.length))):h==""?(u.e_stop(l),d("")):h&&h!=""&&h!=""&&E.exCommandHistoryController.reset()}function o(l,f){var d=new u.StringStream(f),h={};try{if(ue.parseInput_(e,d,h),h.commandName!="s"){$e(e);return}var g=ue.matchCommand_(h.commandName);if(!g||(ue.parseCommandArgs_(d,h,g),!h.argString))return;var m=Ht(h.argString.slice(1),!0,!0);m&&ut(e,m)}catch{}}if(r.type=="keyToEx")ue.processCommand(e,r.exArgs.input);else{var s={onClose:n,onKeyDown:i,onKeyUp:o,prefix:":"};t.visualMode&&(s.value="'<,'>",s.selectValueOnOpen=!1),Ze(e,s)}},evalInput:function(e,t){var r=t.inputState,n=r.motion,i=r.motionArgs||{repeat:1},o=r.operator,s=r.operatorArgs||{},l=r.registerName,f=t.sel,d=V(t.visualMode?ie(e,f.head):e.getCursor("head")),h=V(t.visualMode?ie(e,f.anchor):e.getCursor("anchor")),g=V(d),m=V(h),C,v,w;if(o&&this.recordLastEdit(t,r),r.repeatOverride!==void 0?w=r.repeatOverride:w=r.getRepeat(),w>0&&i.explicitRepeat?i.repeatIsExplicit=!0:(i.noRepeat||!i.explicitRepeat&&w===0)&&(w=1,i.repeatIsExplicit=!1),r.selectedCharacter&&(i.selectedCharacter=s.selectedCharacter=r.selectedCharacter),i.repeat=w,Z(e),n){var S=Se[n](e,d,i,t,r);if(t.lastMotion=Se[n],!S)return;if(i.toJumplist){var T=E.jumpList,M=T.cachedCursor;M?(Tt(e,M,S),delete T.cachedCursor):Tt(e,d,S)}S instanceof Array?(v=S[0],C=S[1]):C=S,C||(C=V(d)),t.visualMode?(t.visualBlock&&C.ch===1/0||(C=ie(e,C,g)),v&&(v=ie(e,v)),v=v||m,f.anchor=v,f.head=C,Ve(e),Te(e,t,"<",q(v,C)?v:C),Te(e,t,">",q(v,C)?C:v)):o||(C=ie(e,C,g),e.setCursor(C.line,C.ch))}if(o){if(s.lastSel){v=m;var O=s.lastSel,N=Math.abs(O.head.line-O.anchor.line),R=Math.abs(O.head.ch-O.anchor.ch);O.visualLine?C=new a(m.line+N,m.ch):O.visualBlock?C=new a(m.line+N,m.ch+R):O.head.line==O.anchor.line?C=new a(m.line,m.ch+R):C=new a(m.line+N,m.ch),t.visualMode=!0,t.visualLine=O.visualLine,t.visualBlock=O.visualBlock,f=t.sel={anchor:v,head:C},Ve(e)}else t.visualMode&&(s.lastSel={anchor:V(f.anchor),head:V(f.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var U,z,P,A,$;if(t.visualMode){U=oe(f.head,f.anchor),z=Ae(f.head,f.anchor),P=t.visualLine||s.linewise,A=t.visualBlock?"block":P?"line":"char";var ve=c(e,U,z);if($=at(e,{anchor:ve.start,head:ve.end},A),P){var re=$.ranges;if(A=="block")for(var ge=0;gel:h.lined&&i.line==d?It(e,t,r,n,!0):(r.toFirstChar&&(o=Me(e.getLine(l)),n.lastHPos=o),n.lastHSPos=e.charCoords(new a(l,o),"div").left,new a(l,o))},moveByDisplayLines:function(e,t,r,n){var i=t;switch(n.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:n.lastHSPos=e.charCoords(i,"div").left}var o=r.repeat,s=e.findPosV(i,r.forward?o:-o,"line",n.lastHSPos);if(s.hitSide)if(r.forward){var l=e.charCoords(s,"div"),f={top:l.top+8,left:n.lastHSPos};s=e.coordsChar(f,"div")}else{var d=e.charCoords(new a(e.firstLine(),0),"div");d.left=n.lastHSPos,s=e.coordsChar(d,"div")}return n.lastHPos=s.ch,s},moveByPage:function(e,t,r){var n=t,i=r.repeat;return e.findPosV(n,r.forward?i:-i,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return Bt(e,t,r.repeat,n).start},moveBySentence:function(e,t,r){var n=r.forward?1:-1;return Kr(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var i=e.getScrollInfo(),o=null,s=r.repeat;s||(s=i.clientHeight/(2*e.defaultTextHeight()));var l=e.charCoords(t,"local");if(r.repeat=s,o=Se.moveByDisplayLines(e,t,r,n),!o)return null;var f=e.charCoords(o,"local");return e.scrollTo(null,i.top+f.top-l.top),o},moveByWords:function(e,t,r){return Br(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,i=lt(e,n,r.forward,r.selectedCharacter,t),o=r.forward?-1:1;return At(o,r),i?(i.ch+=o,i):null},moveToCharacter:function(e,t,r){var n=r.repeat;return At(0,r),lt(e,n,r.forward,r.selectedCharacter,t)||t},moveToSymbol:function(e,t,r){var n=r.repeat;return r.selectedCharacter&&Ir(e,n,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var i=r.repeat;return n.lastHPos=i-1,n.lastHSPos=e.charCoords(t,"div").left,Nr(e,i)},moveToEol:function(e,t,r,n){return It(e,t,r,n,!1)},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return new a(r.line,Me(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){for(var r=t,n=r.line,i=r.ch,o=e.getLine(n),s;i"?/[(){}[\]<>]/:/[(){}[\]]/,d=e.findMatchingBracket(new a(n,i),{bracketRegex:f});return d.to}else return r},moveToStartOfLine:function(e,t){return new a(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var n=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(n=r.repeat-e.getOption("firstLineNumber")),new a(n,Me(e.getLine(n)))},moveToStartOfDisplayLine:function(e){return e.execCommand("goLineLeft"),e.getCursor()},moveToEndOfDisplayLine:function(e){e.execCommand("goLineRight");var t=e.getCursor();return t.sticky=="before"&&t.ch--,t},textObjectManipulation:function(e,t,r,n){var i={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},o={"'":!0,'"':!0,"`":!0},s=r.selectedCharacter||"";s=="b"?s="(":s=="B"&&(s="{");var l=!r.textObjectInner,f,d;if(i[s]){if(d=!0,f=Pt(e,t,s,l),!f){var h=e.getSearchCursor(new RegExp("\\"+s,"g"),t);h.find()&&(f=Pt(e,h.from(),s,l))}}else if(o[s])d=!0,f=Dr(e,t,s,l);else if(s==="W"||s==="w")for(var g=r.repeat||1;g-- >0;){var m=st(e,{inclusive:l,innerWord:!l,bigWord:s==="W",noSymbol:s==="W",multiline:!0},f&&f.end);m&&(f||(f=m),f.end=m.end)}else if(s==="p")if(f=Bt(e,t,r.repeat,0,l),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var C=n.inputState.operatorArgs;C&&(C.linewise=!0),f.end.line--}else if(s==="t")f=Or(e,t,l);else if(s==="s"){var v=e.getLine(t.line);t.ch>0&&Pe(v[t.ch])&&(t.ch-=1);var w=Nt(e,t,r.repeat,1,l),S=Nt(e,t,r.repeat,-1,l);te(e.getLine(S.line)[S.ch])&&te(e.getLine(w.line)[w.ch-1])&&(S={line:S.line,ch:S.ch+1}),f={start:S,end:w}}return f?e.state.vim.visualMode?Lr(e,f.start,f.end,d):[f.start,f.end]:null},repeatLastCharacterSearch:function(e,t,r){var n=E.lastCharacterSearch,i=r.repeat,o=r.forward===n.forward,s=(n.increment?1:0)*(o?-1:1);e.moveH(-s,"char"),r.inclusive=!!o;var l=lt(e,i,o,n.selectedCharacter);return l?(l.ch+=s,l):(e.moveH(s,"char"),t)}};function gr(e,t){Se[e]=t}function St(e,t){for(var r=[],n=0;ns.line&&(l=new a(l.line-1,Number.MAX_VALUE))),e.replaceRange("",s,l),n=s}E.registerController.pushText(t.registerName,"change",i,t.linewise,r.length>1),He.enterInsertMode(e,{head:n},e.state.vim)},delete:function(e,t,r){var n,i,o=e.state.vim;if(o.visualBlock){i=e.getSelection();var f=St("",r.length);e.replaceSelections(f),n=oe(r[0].head,r[0].anchor)}else{var s=r[0].anchor,l=r[0].head;t.linewise&&l.line!=e.firstLine()&&s.line==e.lastLine()&&s.line==l.line-1&&(s.line==e.firstLine()?s.ch=0:s=new a(s.line-1,ne(e,s.line-1))),i=e.getRange(s,l),e.replaceRange("",s,l),n=s,t.linewise&&(n=Se.moveToFirstNonWhiteSpaceCharacter(e,s))}return E.registerController.pushText(t.registerName,"delete",i,t.linewise,o.visualBlock),ie(e,n)},indent:function(e,t,r){var n=e.state.vim,i=n.visualMode&&t.repeat||1;if(n.visualBlock){for(var o=e.getOption("tabSize"),s=e.getOption("indentWithTabs")?" ":" ".repeat(o),l,f=r.length-1;f>=0;f--)if(l=oe(r[f].anchor,r[f].head),t.indentRight)e.replaceRange(s.repeat(i),l,l);else{for(var d=e.getLine(l.line),h=0,g=0;gi&&t.linewise&&s--,t.keepCursor?n:new a(s,0)}},changeCase:function(e,t,r,n,i){for(var o=e.getSelections(),s=[],l=t.toLower,f=0;f{const h=d.charCodeAt(0);return h>=65&&h<=90?String.fromCharCode(65+(h-65+13)%26):h>=97&&h<=122?String.fromCharCode(97+(h-97+13)%26):d}).join("");s.push(f)}return e.replaceSelections(s),t.shouldMoveCursor?i:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?Se.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:oe(r[0].anchor,r[0].head)}};function yr(e,t){it[e]=t}var He={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,i=t.forward,o=E.jumpList,s=o.move(e,i?n:-n),l=s?s.find():void 0;l=l||e.getCursor(),e.setCursor(l)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,i=e.defaultTextHeight(),o=e.getScrollInfo().top,s=i*n,l=t.forward?o+s:o-s,f=V(e.getCursor()),d=e.charCoords(f,"local");if(t.forward)l>d.top?(f.line+=(l-d.top)/i,f.line=Math.ceil(f.line),e.setCursor(f),d=e.charCoords(f,"local"),e.scrollTo(null,d.top)):e.scrollTo(null,l);else{var h=l+e.getScrollInfo().clientHeight;h=i.anchor.line?o=G(i.head,0,1):o=new a(i.anchor.line,0)}else if(n=="inplace"){if(r.visualMode)return}else n=="lastEdit"&&(o=$t(e)||o);e.setOption("disableInput",!1),t&&t.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),u.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),u.signal(e,"vim-mode-change",{mode:"insert"})),E.macroModeState.isPlaying||(e.on("change",jt),r.insertEnd&&r.insertEnd.clear(),r.insertEnd=e.setBookmark(o,{insertLeft:!0}),u.on(e.getInputField(),"keydown",zt)),r.visualMode&&xe(e),Lt(e,o,s)}},toggleVisualMode:function(e,t,r){var n=t.repeat,i=e.getCursor(),o;if(r.visualMode)r.visualLine!=!!t.linewise||r.visualBlock!=!!t.blockwise?(r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,u.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),Ve(e)):xe(e);else{r.visualMode=!0,r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,o=ie(e,new a(i.line,i.ch+n-1));var s=c(e,i,o);r.sel={anchor:s.start,head:s.end},u.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),Ve(e),Te(e,r,"<",oe(i,o)),Te(e,r,">",Ae(i,o))}},reselectLastSelection:function(e,t,r){var n=r.lastSelection;if(r.visualMode&&Et(e,r),n){var i=n.anchorMark.find(),o=n.headMark.find();if(!i||!o)return;r.sel={anchor:i,head:o},r.visualMode=!0,r.visualLine=n.visualLine,r.visualBlock=n.visualBlock,Ve(e),Te(e,r,"<",oe(i,o)),Te(e,r,">",Ae(i,o)),u.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var n,i;if(r.visualMode){if(n=e.getCursor("anchor"),i=e.getCursor("head"),q(i,n)){var o=i;i=n,n=o}i.ch=ne(e,i.line)-1}else{var s=Math.max(t.repeat,2);n=e.getCursor(),i=ie(e,new a(n.line+s-1,1/0))}for(var l=0,f=n.line;f{this.continuePaste(e,t,r,o,n)});else{var i=n.toString();this.continuePaste(e,t,r,i,n)}},continuePaste:function(e,t,r,n,i){var o=V(e.getCursor());if(n){if(t.matchIndent){var s=e.getOption("tabSize"),l=function(re){var ge=re.split(" ").length-1,Be=re.split(" ").length-1;return ge*s+Be*1},f=e.getLine(e.getCursor().line),d=l(f.match(/^\s*/)[0]),h=n.replace(/\n$/,""),g=n!==h,m=l(n.match(/^\s*/)[0]),n=h.replace(/^\s*/gm,function(re){var ge=d+(l(re)-m);if(ge<0)return"";if(e.getOption("indentWithTabs")){var Be=Math.floor(ge/s);return Array(Be+1).join(" ")}else return Array(ge+1).join(" ")});n+=g?` `:""}t.repeat>1&&(n=Array(t.repeat+1).join(n));var C=i.linewise,v=i.blockwise,w=v?n.split(` `):void 0;if(w){C&&w.pop();for(var S=0;Se.lastLine()&&e.replaceRange(` `,new a(A,0));var $=ne(e,A);$f.length&&(o=f.length),s=new a(i.line,o)}var d=c(e,i,s);if(i=d.start,s=d.end,n==` `)r.visualMode||e.replaceRange("",i,s),(u.commands.newlineAndIndentContinueComment||u.commands.newlineAndIndent)(e);else{var h=e.getRange(i,s);if(h=h.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n),h=h.replace(/[^\n]/g,n),r.visualBlock){var g=new Array(e.getOption("tabSize")+1).join(" ");h=e.getSelection(),h=h.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n);var m=h.replace(/\t/g,g).replace(/[^\n]/g,n).split(` `);e.replaceSelections(m)}else e.replaceRange(h,i,s);r.visualMode?(i=q(l[0].anchor,l[0].head)?l[0].anchor:l[0].head,e.setCursor(i),xe(e,!1)):e.setCursor(G(s,0,-1))}},incrementNumberToken:function(e,t){for(var r=e.getCursor(),n=e.getLine(r.line),i=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,o,s,l,f;(o=i.exec(n))!==null&&(s=o.index,l=s+o[0].length,!(r.chf&&(h=-1),f+=h,f>l&&(f-=2)}return new a(o,f)}function Ye(e){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}function G(e,t,r){return typeof t=="object"&&(r=t.ch,t=t.line),new a(e.line+t,e.ch+r)}function Cr(e,t,r,n){n.operator&&(r="operatorPending");for(var i,o=[],s=[],l=Ge?t.length-k:0,f=l;f",n=t.slice(-10)=="";if(r||n){var i=t.length-(r?11:10),o=e.slice(0,i),s=t.slice(0,i);return o==s&&e.length>i?"full":s.indexOf(o)==0?"partial":!1}else return e==t?"full":t.indexOf(e)==0?"partial":!1}function wr(e){var t=/^.*(<[^>]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"":case"":r=` `;break;case"":case"":r=" ";break;default:r="";break}return r}function xt(e,t,r){return function(){for(var n=0;n2&&(t=oe.apply(void 0,Array.prototype.slice.call(arguments,1))),q(e,t)?e:t}function Ae(e,t){return arguments.length>2&&(t=Ae.apply(void 0,Array.prototype.slice.call(arguments,1))),q(e,t)?t:e}function Mt(e,t,r){var n=q(e,t),i=q(t,r);return n&&i}function ne(e,t){return e.getLine(t).length}function ot(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Sr(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function xr(e,t,r){var n=ne(e,t),i=new Array(r-n+1).join(" ");e.setCursor(new a(t,n)),e.replaceRange(i,e.getCursor())}function bt(e,t){var r=[],n=e.listSelections(),i=V(e.clipPos(t)),o=!pe(t,i),s=e.getCursor("head"),l=Mr(n,s),f=pe(n[l].head,n[l].anchor),d=n.length-1,h=d-l>l?d:0,g=n[h].anchor,m=Math.min(g.line,i.line),C=Math.max(g.line,i.line),v=g.ch,w=i.ch,S=n[h].head.ch-v,T=w-v;S>0&&T<=0?(v++,o||w--):S<0&&T>=0?(v--,f||w++):S<0&&T==-1&&(v--,w++);for(var M=m;M<=C;M++){var O={anchor:new a(M,v),head:new a(M,w)};r.push(O)}return e.setSelections(r),t.ch=w,g.ch=v,g}function Lt(e,t,r){for(var n=[],i=0;if&&(i.line=f),i.ch=ne(e,i.line)}return{ranges:[{anchor:o,head:i}],primary:0}}else if(r=="block"){var d=Math.min(o.line,i.line),h=o.ch,g=Math.max(o.line,i.line),m=i.ch;h0&&o&&te(o);o=i.pop())r.line--,r.ch=0;o?(r.line--,r.ch=ne(e,r.line)):r.ch=0}}function Ar(e,t,r){t.ch=0,r.ch=0,r.line++}function Me(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function st(e,{inclusive:t,innerWord:r,bigWord:n,noSymbol:i,multiline:o},s){var l=s||Er(e),f=e.getLine(l.line),d=f,h=l.line,g=h,m=l.ch,C,v=i?j[0]:B[0];if(r&&/\s/.test(f.charAt(m)))v=function(N){return/\s/.test(N)};else{for(;!v(f.charAt(m));)if(m++,m>=f.length){if(!o)return null;m--,C=Rt(e,l,!0,n,!0);break}n?v=B[0]:(v=j[0],v(f.charAt(m))||(v=j[1]))}for(var w=m,S=m;v(f.charAt(S))&&S>=0;)S--;if(S++,C)w=C.to,g=C.line,d=e.getLine(g),!d&&w==0&&w++;else for(;v(f.charAt(w))&&w0;)S--;!S&&!M&&(S=O)}}return{start:new a(h,S),end:new a(g,w)}}function Or(e,t,r){var n=t;if(!u.findMatchingTag||!u.findEnclosingTag)return{start:n,end:n};var i=u.findMatchingTag(e,t)||u.findEnclosingTag(e,t);return!i||!i.open||!i.close?{start:n,end:n}:r?{start:i.open.from,end:i.close.to}:{start:i.open.to,end:i.close.from}}function Tt(e,t,r){pe(t,r)||E.jumpList.add(e,t,r)}function At(e,t){E.lastCharacterSearch.increment=e,E.lastCharacterSearch.forward=t.forward,E.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var Rr={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},Ot={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return e.index===0&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t=e.lastCh==="*"&&e.nextCh==="/";return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb=e.symb==="m"?"{":"}",e.reverseSymb=e.symb==="{"?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if(e.nextCh==="#"){var t=e.lineText.match(/^#(\w+)/)?.[1];if(t==="endif"){if(e.forward&&e.depth===0)return!0;e.depth++}else if(t==="if"){if(!e.forward&&e.depth===0)return!0;e.depth--}if(t==="else"&&e.depth===0)return!0}return!1}}};function Ir(e,t,r,n){var i=V(e.getCursor()),o=r?1:-1,s=r?e.lineCount():-1,l=i.ch,f=i.line,d=e.getLine(f),h={lineText:d,nextCh:d.charAt(l),lastCh:null,index:l,symb:n,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[n],forward:r,depth:0,curMoveThrough:!1},g=Rr[n];if(!g)return i;var m=Ot[g].init,C=Ot[g].isComplete;for(m&&m(h);f!==s&&t;){if(h.index+=o,h.nextCh=h.lineText.charAt(h.index),!h.nextCh){if(f+=o,h.lineText=e.getLine(f)||"",o>0)h.index=0;else{var v=h.lineText.length;h.index=v>0?v-1:0}h.nextCh=h.lineText.charAt(h.index)}C(h)&&(i.line=f,i.ch=h.index,t--)}return h.nextCh||h.curMoveThrough?new a(f,h.index):i}function Rt(e,t,r,n,i){var o=t.line,s=t.ch,l=e.getLine(o),f=r?1:-1,d=n?B:j;if(i&&l==""){if(o+=f,l=e.getLine(o),!ae(e,o))return null;s=r?0:l.length}for(;;){if(i&&l=="")return{from:0,to:0,line:o};for(var h=f>0?l.length:-1,g=h,m=h;s!=h;){for(var C=!1,v=0;v0?0:l.length}}function Br(e,t,r,n,i,o){var s=V(t),l=[];(n&&!i||!n&&i)&&r++;for(var f=!(n&&i),d=0;d0;)m(h,n)&&r--,h+=n;return{start:new a(h,0),end:t}}var C=e.state.vim;if(C.visualLine&&m(o,1,!0)){var v=C.sel.anchor;m(v.line,-1,!0)&&(!i||v.line!=o)&&(o+=1)}var w=g(o);for(h=o;h<=l&&r;h++)m(h,1,!0)&&(!i||g(h)!=w)&&r--;for(d=new a(h,0),h>l&&!w?w=!0:i=!1,h=o;h>s&&!((!i||g(h)==w||h==o)&&m(h,-1,!0));h--);return f=new a(h,0),{start:f,end:d}}function Nt(e,t,r,n,i){function o(d){d.line!==null&&(d.pos+d.dir<0||d.pos+d.dir>=d.line.length?d.line=null:d.pos+=d.dir)}function s(d,h,g,m){var C=d.getLine(h),v={line:C,ln:h,pos:g,dir:m};if(v.line==="")return{ln:v.ln,pos:v.pos};var w=v.pos;for(o(v);v.line!==null;){if(w=v.pos,Pe(v.line[v.pos]))if(i){for(o(v);v.line!==null&&te(v.line[v.pos]);)w=v.pos,o(v);return{ln:v.ln,pos:w+1}}else return{ln:v.ln,pos:v.pos+1};o(v)}return{ln:v.ln,pos:w+1}}function l(d,h,g,m){var C=d.getLine(h),v={line:C,ln:h,pos:g,dir:m};if(v.line==="")return{ln:v.ln,pos:v.pos};var w=v.pos;for(o(v);v.line!==null;){if(!te(v.line[v.pos])&&!Pe(v.line[v.pos]))w=v.pos;else if(Pe(v.line[v.pos]))return i?te(v.line[v.pos+1])?{ln:v.ln,pos:v.pos+1}:{ln:v.ln,pos:w}:{ln:v.ln,pos:w};o(v)}return v.line=C,i&&te(v.line[v.pos])?{ln:v.ln,pos:v.pos}:{ln:v.ln,pos:w}}for(var f={ln:t.line,pos:t.ch};r>0;)n<0?f=l(e,f.ln,f.pos,n):f=s(e,f.ln,f.pos,n),r--;return new a(f.ln,f.pos)}function Kr(e,t,r,n){function i(f,d){if(d.line!==null)if(d.pos+d.dir<0||d.pos+d.dir>=d.line.length){if(d.ln+=d.dir,!ae(f,d.ln)){d.line=null;return}d.line=f.getLine(d.ln),d.pos=d.dir>0?0:d.line.length-1}else d.pos+=d.dir}function o(f,d,h,g){var S=f.getLine(d),m=S==="",C={line:S,ln:d,pos:h,dir:g},v={ln:C.ln,pos:C.pos},w=C.line==="";for(i(f,C);C.line!==null;){if(v.ln=C.ln,v.pos=C.pos,C.line===""&&!w)return{ln:C.ln,pos:C.pos};if(m&&C.line!==""&&!te(C.line[C.pos]))return{ln:C.ln,pos:C.pos};Pe(C.line[C.pos])&&!m&&(C.pos===C.line.length-1||te(C.line[C.pos+1]))&&(m=!0),i(f,C)}var S=f.getLine(v.ln);v.pos=0;for(var T=S.length-1;T>=0;--T)if(!te(S[T])){v.pos=T;break}return v}function s(f,d,h,g){var S=f.getLine(d),m={line:S,ln:d,pos:h,dir:g},C=m.ln,v=null,w=m.line==="";for(i(f,m);m.line!==null;){if(m.line===""&&!w)return v!==null?{ln:C,pos:v}:{ln:m.ln,pos:m.pos};if(Pe(m.line[m.pos])&&v!==null&&!(m.ln===C&&m.pos+1===v))return{ln:C,pos:v};m.line!==""&&!te(m.line[m.pos])&&(w=!1,C=m.ln,v=m.pos),i(f,m)}var S=f.getLine(C);v=0;for(var T=0;T0;)n<0?l=s(e,l.ln,l.pos,n):l=o(e,l.ln,l.pos,n),r--;return new a(l.ln,l.pos)}function Pt(e,t,r,n){var i=t,o={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[r],s={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[r],l=e.getLine(i.line).charAt(i.ch),f=l===s?1:0,d=e.scanForBracket(new a(i.line,i.ch+f),-1,void 0,{bracketRegex:o}),h=e.scanForBracket(new a(i.line,i.ch+f),1,void 0,{bracketRegex:o});if(!d||!h)return null;var g=d.pos,m=h.pos;if(g.line==m.line&&g.ch>m.ch||g.line>m.line){var C=g;g=m,m=C}return n?m.ch+=1:g.ch+=1,{start:g,end:m}}function Dr(e,t,r,n){var i=V(t),o=e.getLine(i.line),s=o.split(""),l,f,d,h,g=s.indexOf(r);if(i.ch-1&&!l;d--)s[d]==r&&(l=d+1);if(l&&!f)for(d=l,h=s.length;d"},r={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},n=t.m,i=e.replace(/\\.|[\[|(){+*?.$^<>]/g,function(s){if(s[0]==="\\"){var l=s[1];return l==="}"||n.indexOf(l)!=-1?l:l in t?(n=t[l],""):l in r?r[l]:s}else return n.indexOf(s)!=-1?r[s]||"\\"+s:s}),o=i.indexOf("\\zs");return o!=-1&&(i="(?<="+i.slice(0,o)+")"+i.slice(o+3)),o=i.indexOf("\\ze"),o!=-1&&(i=i.slice(0,o)+"(?="+i.slice(o+3)+")"),i}var _t={"\\n":` `,"\\r":"\r","\\t":" "};function $r(e){for(var t=!1,r=[],n=-1;n=t&&e<=r:e==t}function ft(e){var t=e.getScrollInfo(),r=6,n=10,i=e.coordsChar({left:0,top:r+t.top},"local"),o=t.clientHeight-n+t.top,s=e.coordsChar({left:0,top:o},"local");return{top:i.line,bottom:s.line}}function et(e,t,r){if(r=="'"||r=="`")return E.jumpList.find(e,-1)||new a(0,0);if(r==".")return $t(e);var n=t.marks[r];return n&&n.find()}function $t(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var t=e.doc.history.done,r=t.length;r--;)if(t[r].changes)return V(t[r].changes[0].to)}class qr{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(t,r,n){var i=this;t.operation(function(){t.curOp&&(t.curOp.isVimOp=!0),i._processCommand(t,r,n)})}_processCommand(t,r,n){var i=t.state.vim,o=E.registerController.getRegister(":"),s=o.toString(),l=new u.StringStream(r);o.setText(r);var f=n||{};f.input=r;try{this.parseInput_(t,l,f)}catch(g){throw K(t,g+""),g}i.visualMode&&xe(t);var d,h;if(!f.commandName)f.line!==void 0&&(h="move");else if(d=this.matchCommand_(f.commandName),d){if(h=d.name,d.excludeFromCommandHistory&&o.setText(s),this.parseCommandArgs_(l,f,d),d.type=="exToKey"){je(t,d.toKeys||"",d);return}else if(d.type=="exToEx"){this.processCommand(t,d.toInput||"");return}}if(!h){K(t,'Not an editor command ":'+r+'"');return}try{Wt[h](t,f),(!d||!d.possiblyAsync)&&f.callback&&f.callback()}catch(g){throw K(t,g+""),g}}parseInput_(t,r,n){r.eatWhile(":"),r.eat("%")?(n.line=t.firstLine(),n.lineEnd=t.lastLine()):(n.line=this.parseLineSpec_(t,r),n.line!==void 0&&r.eat(",")&&(n.lineEnd=this.parseLineSpec_(t,r))),n.line==null?t.state.vim.visualMode?(n.selectionLine=et(t,t.state.vim,"<")?.line,n.selectionLineEnd=et(t,t.state.vim,">")?.line):n.selectionLine=t.getCursor().line:(n.selectionLine=n.line,n.selectionLineEnd=n.lineEnd);var i=r.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return i?n.commandName=i[1]:n.commandName=(r.match(/.*/)||[""])[0],n}parseLineSpec_(t,r){var n=r.match(/^(\d+)/);if(n)return parseInt(n[1],10)-1;switch(r.next()){case".":return this.parseLineSpecOffset_(r,t.getCursor().line);case"$":return this.parseLineSpecOffset_(r,t.lastLine());case"'":var i=r.next()||"",o=et(t,t.state.vim,i);if(!o)throw new Error("Mark not set");return this.parseLineSpecOffset_(r,o.line);case"-":case"+":return r.backUp(1),this.parseLineSpecOffset_(r,t.getCursor().line);default:r.backUp(1);return}}parseLineSpecOffset_(t,r){var n=t.match(/^([+-])?(\d+)/);if(n){var i=parseInt(n[2],10);n[1]=="-"?r-=i:r+=i}return r}parseCommandArgs_(t,r,n){if(!t.eol()){r.argString=t.match(/.*/)?.[0];var i=n.argDelimiter||/\s+/,o=ot(r.argString||"").split(i);o.length&&o[0]&&(r.args=o)}}matchCommand_(t){for(var r=t.length;r>0;r--){var n=t.substring(0,r);if(this.commandMap_[n]){var i=this.commandMap_[n];if(i.name.indexOf(t)===0)return i}}}buildCommandMap_(){this.commandMap_={};for(var t=0;t0?i.join("="):void 0,l=!1,f=!1;if(o.charAt(o.length-1)=="?"){if(s)throw Error("Trailing characters: "+t.argString);o=o.substring(0,o.length-1),l=!0}else o.charAt(o.length-1)=="!"&&(o=o.substring(0,o.length-1),f=!0);s===void 0&&o.substring(0,2)=="no"&&(o=o.substring(2),s=!1);var d=Ee[o]&&Ee[o].type=="boolean";if(d&&(f?s=!fe(o,e,n):s==null&&(s=!0)),!d&&s===void 0||l){var h=fe(o,e,n);h instanceof Error?K(e,h.message):h===!0||h===!1?K(e," "+(h?"":"no")+o):K(e," "+o+"="+h)}else{var g=Xe(o,s,e,n);g instanceof Error&&K(e,g.message)}},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=E.registerController.registers,i=`----------Registers---------- `;if(r)for(var l=r.join(""),f=0;f1)return"Invalid arguments";o=$&&"decimal"||ve&&"hex"||re&&"octal"}A[2]&&(s=new RegExp(A[2].substr(1,A[2].length-2),n?"i":""))}}var f=l();if(f){K(e,f+": "+t.argString);return}var d=t.line||e.firstLine(),h=t.lineEnd||t.line||e.lastLine();if(d==h)return;var g=new a(d,0),m=new a(h,ne(e,h)),C=e.getRange(g,m).split(` `),v=o=="decimal"?/(-?)([\d]+)/:o=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:o=="octal"?/([0-7]+)/:null,w=o=="decimal"?10:o=="hex"?16:o=="octal"?8:void 0,S=[],T=[];if(o||s)for(var M=0;M=d){K(e,"Invalid argument: "+t.argString.substring(i));return}for(var h=0;h<=d-f;h++){var g=String.fromCharCode(f+h);delete r.marks[g]}}else{K(e,"Invalid argument: "+s+"-");return}}else o&&delete r.marks[o]}}},ue=new qr;ce.defineEx("version","ve",e=>{K(e,"Codemirror-vim version: 6.3.0")});function Xr(e,t,r,n,i,o,s,l,f){e.state.vim.exMode=!0;var d=!1,h=0,g,m,C;function v(){e.operation(function(){for(;!d;)w(),T();M()})}function w(){var N="",R=o.match||o.pos&&o.pos.match;if(R)N=l.replace(/\$(\d{1,3}|[$&])/g,function(P,A){if(A=="$")return"$";if(A=="&")return R[0];for(var $=A;parseInt($)>=R.length&&$.length>0;)$=$.slice(0,$.length-1);return $?R[$]+A.slice($.length,A.length):P});else{var U=e.getRange(o.from(),o.to());N=U.replace(s,l)}var z=o.to().line;o.replace(N),m=o.to().line,i+=m-z,C=m":case"":case"":M(U);break}return d&&M(U),!0}if(T(),d){K(e,"No matches for "+s+(fe("pcre")?" (set nopcre to use vim regexps)":""));return}if(!t){v(),f&&f();return}Ze(e,{prefix:ke("span","replace with ",ke("strong",l)," (y/n/a/q/l)"),onKeyDown:O})}function Oe(e,t){var r=e.state.vim,n=E.macroModeState,i=E.registerController.getRegister("."),o=n.isPlaying,s=n.lastInsertModeChanges;o||(e.off("change",jt),r.insertEnd&&r.insertEnd.clear(),r.insertEnd=void 0,u.off(e.getInputField(),"keydown",zt)),!o&&r.insertModeRepeat&&r.insertModeRepeat>1&&(Jt(e,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t||e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),i.setText(s.changes.join("")),u.signal(e,"vim-mode-change",{mode:"normal"}),n.isRecording&&rn(n)}function ct(e){p.unshift(e),e.keys&&Gr(e.keys)}function Gr(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){t&&(y[t]||(y[t]=0),y[t]++)})}function Yr(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){y[t]&&y[t]--})}function Zr(e,t,r,n,i){var o={keys:e,type:t};o[t]=r,o[t+"Args"]=n;for(var s in i)o[s]=i[s];ct(o)}Ke("insertModeEscKeysTimeout",200,"number");function en(e,t,r,n){var i=E.registerController.getRegister(n);if(n==":"){i.keyBuffer[0]&&ue.processCommand(e,i.keyBuffer[0]),r.isPlaying=!1;return}var o=i.keyBuffer,s=0;r.isPlaying=!0,r.replaySearchQueries=i.searchQueries.slice(0);for(var l=0;l|./gi;d=g.exec(f);)if(h=d[0],ce.handleKey(e,h,"macro"),t.insertMode){var m=i.insertModeChanges[s++].changes;E.macroModeState.lastInsertModeChanges.changes=m,Xt(e,m,1),Oe(e)}r.isPlaying=!1}function tn(e,t){if(!e.isPlaying){var r=e.latestRegister,n=E.registerController.getRegister(r);n&&n.pushText(t)}}function rn(e){if(!e.isPlaying){var t=e.latestRegister,r=E.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function nn(e,t){if(!e.isPlaying){var r=e.latestRegister,n=E.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function jt(e,t){var r=E.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(var i=e.state.vim;t;){if(n.expectCursorActivityForChange=!0,n.ignoreCount>1)n.ignoreCount--;else if(t.origin=="+input"||t.origin=="paste"||t.origin===void 0){var o=e.listSelections().length;o>1&&(n.ignoreCount=o);var s=t.text.join(` `);if(n.maybeReset&&(n.changes=[],n.maybeReset=!1),s)if(e.state.overwrite&&!/\n/.test(s))n.changes.push([s]);else{if(s.length>1){var l=i&&i.insertEnd&&i.insertEnd.find(),f=e.getCursor();if(l&&l.line==f.line){var d=l.ch-f.ch;d>0&&d",Ae(n,r))}else t.insertMode||(t.lastHPos=e.getCursor().ch)}function zt(e){var t=E.macroModeState,r=t.lastInsertModeChanges,n=u.keyName?u.keyName(e):e.key;n&&(n.indexOf("Delete")!=-1||n.indexOf("Backspace")!=-1)&&(r.maybeReset&&(r.changes=[],r.maybeReset=!1),r.changes.push(new rt(n,e)))}function Jt(e,t,r,n){var i=E.macroModeState;i.isPlaying=!0;var o=t.lastEditActionCommand,s=t.inputState;function l(){o?Ie.processAction(e,t,o):Ie.evalInput(e,t)}function f(h){if(i.lastInsertModeChanges.changes.length>0){h=t.lastEditActionCommand?h:1;var g=i.lastInsertModeChanges;Xt(e,g.changes,h)}}if(t.inputState=t.lastEditInputState,o&&o.interlaceInsertRepeat)for(var d=0;d")return Z(n),!0}var f=n.isInMultiSelectMode();if(o.wasInVisualBlock&&!f?o.wasInVisualBlock=!1:f&&o.visualBlock&&(o.wasInVisualBlock=!0),t==""&&!o.insertMode&&!o.visualMode&&f&&o.status=="")Z(n);else if(s||!f||n.inVirtualSelectionMode)i=ce.handleKey(n,t,r);else{var d=ht(o),h=o.inputState.changeQueueList||[];n.operation(function(){n.curOp&&(n.curOp.isVimOp=!0);var g=0;n.forEachSelection(function(){n.state.vim.inputState.changeQueue=h[g];var m=n.getCursor("head"),C=n.getCursor("anchor"),v=q(m,C)?0:-1,w=q(m,C)?-1:0;m=G(m,0,v),C=G(C,0,w),n.state.vim.sel.head=m,n.state.vim.sel.anchor=C,i=ce.handleKey(n,t,r),n.virtualSelection&&(h[g]=n.state.vim.inputState.changeQueue,n.state.vim=ht(d)),g++}),n.curOp?.cursorActivity&&!i&&(n.curOp.cursorActivity=!1),n.state.vim=o,o.inputState.changeQueueList=h,o.inputState.changeQueue=null},!0)}return i&&!o.visualMode&&!o.insertMode&&o.visualMode!=n.somethingSelected()&&Qt(n,o),i}return yt(),ce}function he(u,a){var c=a.ch,p=a.line+1;p<1&&(p=1,c=0),p>u.lines&&(p=u.lines,c=Number.MAX_VALUE);var y=u.line(p);return Math.min(y.from+Math.max(0,c),y.to)}function ye(u,a){let c=u.lineAt(a);return{line:c.number-1,ch:a-c.from}}class be{constructor(a,c){this.line=a,this.ch=c}}function tr(u,a,c){if(u.addEventListener)u.addEventListener(a,c,!1);else{var p=u._handlers||(u._handlers={});p[a]=(p[a]||[]).concat(c)}}function rr(u,a,c){if(u.removeEventListener)u.removeEventListener(a,c,!1);else{var p=u._handlers,y=p&&p[a];if(y){var k=y.indexOf(c);k>-1&&(p[a]=y.slice(0,k).concat(y.slice(k+1)))}}}function nr(u,a,...c){var p,y=(p=u._handlers)===null||p===void 0?void 0:p[a];if(y)for(var k=0;kY.runScopeHandlers(u.cm6,{key:"Left"},"editor"),Right:u=>Y.runScopeHandlers(u.cm6,{key:"Right"},"editor"),Up:u=>Y.runScopeHandlers(u.cm6,{key:"Up"},"editor"),Down:u=>Y.runScopeHandlers(u.cm6,{key:"Down"},"editor"),Backspace:u=>Y.runScopeHandlers(u.cm6,{key:"Backspace"},"editor"),Delete:u=>Y.runScopeHandlers(u.cm6,{key:"Delete"},"editor")};class I{openDialog(a,c,p){return hn(this,a,c,p)}openNotification(a,c){return cn(this,a,c)}constructor(a){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=a,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(a,c){tr(this,a,c)}off(a,c){rr(this,a,c)}signal(a,c,p){nr(this,a,c,p)}indexFromPos(a){return he(this.cm6.state.doc,a)}posFromIndex(a){return ye(this.cm6.state.doc,a)}foldCode(a){let c=this.cm6,p=c.state.selection.ranges,y=this.cm6.state.doc,k=he(y,a),b=ee.EditorSelection.create([ee.EditorSelection.range(k,k)],0).ranges;c.state.selection.ranges=b,Re.foldCode(c),c.state.selection.ranges=p}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(a,c){typeof a=="object"&&(c=a.ch,a=a.line);var p=he(this.cm6.state.doc,{line:a,ch:c||0});this.cm6.dispatch({selection:{anchor:p}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(a){var c=this.cm6.state.selection.main,p=a=="head"||!a?c.head:a=="anchor"?c.anchor:a=="start"?c.from:a=="end"?c.to:null;if(p==null)throw new Error("Invalid cursor type");return this.posFromIndex(p)}listSelections(){var a=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(c=>({anchor:ye(a,c.anchor),head:ye(a,c.head)}))}setSelections(a,c){var p=this.cm6.state.doc,y=a.map(k=>{var b=he(p,k.head),x=he(p,k.anchor);return b==x?ee.EditorSelection.cursor(b,1):ee.EditorSelection.range(x,b)});this.cm6.dispatch({selection:ee.EditorSelection.create(y,c)})}setSelection(a,c,p){this.setSelections([{anchor:a,head:c}],0),p&&p.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(a){var c=this.cm6.state.doc;return a<0||a>=c.lines?"":this.cm6.state.doc.line(a+1).text}getLineHandle(a){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:a,index:this.indexFromPos(new be(a,0))}}getLineNumber(a){var c=this.$lineHandleChanges;if(!c)return null;for(var p=a.index,y=0;y({from:y.from,to:y.to,insert:a[k]||""}));qe(this,{changes:p})}getSelection(){return this.getSelections().join(` `)}getSelections(){var a=this.cm6;return a.state.selection.ranges.map(c=>a.state.sliceDoc(c.from,c.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(a=>!a.empty)}getInputField(){return this.cm6.contentDOM}clipPos(a){var c=this.cm6.state.doc,p=a.ch,y=a.line+1;y<1&&(y=1,p=0),y>c.lines&&(y=c.lines,p=Number.MAX_VALUE);var k=c.line(y);return p=Math.min(Math.max(0,p),k.to-k.from),new be(y-1,p)}getValue(){return this.cm6.state.doc.toString()}setValue(a){var c=this.cm6;return c.dispatch({changes:{from:0,to:c.state.doc.length,insert:a},selection:ee.EditorSelection.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(a,c){var p=this.cm6.state,y=he(p.doc,a),k=Re.matchBrackets(p,y+1,-1);return k&&k.end?{to:ye(p.doc,k.end.from)}:(k=Re.matchBrackets(p,y,1),k&&k.end?{to:ye(p.doc,k.end.from)}:{to:void 0})}scanForBracket(a,c,p,y){return vn(this,a,c,p,y)}indentLine(a,c){c?this.indentMore():this.indentLess()}indentMore(){Le.indentMore(this.cm6)}indentLess(){Le.indentLess(this.cm6)}execCommand(a){if(a=="indentAuto")I.commands.indentAuto(this);else if(a=="goLineLeft")Le.cursorLineBoundaryBackward(this.cm6);else if(a=="goLineRight"){Le.cursorLineBoundaryForward(this.cm6);let c=this.cm6.state,p=c.selection.main.head;p_.length)return null;let Q=F(_,B).next();return Q.done?null:Q.value}var H=1e4;function j(B,_){var Q=p.cm6.state.doc;for(let W=1;;W++){let J=Math.max(B,_-W*H),ae=F(Q,J,_),se=null;for(;!ae.next().done;)se=ae.value;if(se&&(J==B||se.from>J+10))return se;if(J==B)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(B){var _=p.cm6.state.doc;if(B){let Q=y?b?y.to-1:y.from:x;y=j(0,Q)}else{let Q=y?b?y.to+1:y.to:x;y=D(Q)}return k=y&&{from:ye(_,y.from),to:ye(_,y.to),match:y.match},b=y?y.from==y.to:!1,y&&y.match},from:function(){return k?.from},to:function(){return k?.to},replace:function(B){y&&(qe(p,{changes:{from:y.from,to:y.to,insert:B}}),y.to=y.from+B.length,k&&(k.to=ye(p.cm6.state.doc,y.to)))},get match(){return k&&k.match}}}findPosV(a,c,p,y){let{cm6:k}=this;const b=k.state.doc;let x=p=="page"?k.dom.clientHeight:0;const L=he(b,a);let F=ee.EditorSelection.cursor(L,1,void 0,y),D=Math.round(Math.abs(c));for(let j=0;j0,x):p=="line"&&(F=k.moveVertically(F,c>0));let H=ye(b,F.head);return(c<0&&F.head==0&&y!=0&&a.line==0&&a.ch!=0||c>0&&F.head==b.length&&H.ch!=y&&a.line==H.line)&&(H.hitSide=!0),H}charCoords(a,c){var p=this.cm6.contentDOM.getBoundingClientRect(),y=he(this.cm6.state.doc,a),k=this.cm6.coordsAtPos(y),b=-p.top;return{left:(k?.left||0)-p.left,top:(k?.top||0)+b,bottom:(k?.bottom||0)+b}}coordsChar(a,c){var p=this.cm6.contentDOM.getBoundingClientRect(),y=this.cm6.posAtCoords({x:a.left+p.left,y:a.top+p.top})||0;return ye(this.cm6.state.doc,y)}getScrollInfo(){var a=this.cm6.scrollDOM;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight,width:a.scrollWidth,clientHeight:a.clientHeight,clientWidth:a.clientWidth}}scrollTo(a,c){a!=null&&(this.cm6.scrollDOM.scrollLeft=a),c!=null&&(this.cm6.scrollDOM.scrollTop=c)}scrollIntoView(a,c){if(a){var p=this.indexFromPos(a);this.cm6.dispatch({effects:Y.EditorView.scrollIntoView(p)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(a,c){this.cm6.dom.style.width=a+4+"px",this.cm6.dom.style.height=c+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(a){this.$lineHandleChanges&&this.$lineHandleChanges.push(a);for(let p in this.marks)this.marks[p].update(a.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(p=>p.map(a.changes)));var c=this.curOp=this.curOp||{};a.changes.iterChanges((p,y,k,b,x)=>{(c.$changeStart==null||c.$changeStart>k)&&(c.$changeStart=k),this.$lastChangeEndOffset=b;var L={text:x.toJSON()};c.lastChange?c.lastChange.next=c.lastChange=L:c.lastChange=c.change=L},!0),c.changeHandlers||(c.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var a=this.curOp=this.curOp||{};a.cursorActivityHandlers||(a.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(a,c){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var p=a()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return p}onBeforeEndOperation(){var a=this.curOp,c=!1;a&&(a.change&&Gt(a.changeHandlers,this,a.change),a&&a.cursorActivity&&(Gt(a.cursorActivityHandlers,this,null),a.isVimOp&&(c=!0)),this.curOp=null),c&&this.scrollIntoView()}moveH(a,c){if(c=="char"){var p=this.getCursor();this.setCursor(p.line,p.ch+a)}}setOption(a,c){switch(a){case"keyMap":this.state.keyMap=c;break;case"textwidth":this.state.textwidth=c;break}}getOption(a){switch(a){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(Re.indentUnit)==" ";case"indentUnit":return this.cm6.state.facet(Re.indentUnit).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(a){this.state.overwrite=a}getTokenTypeAt(a){var c,p=this.indexFromPos(a),y=Re.ensureSyntaxTree(this.cm6.state,p),k=y?.resolve(p),b=((c=k?.type)===null||c===void 0?void 0:c.name)||"";return/comment/i.test(b)?"comment":/string/i.test(b)?"string":""}overWriteSelection(a){var c=this.cm6.state.doc,p=this.cm6.state.selection,y=p.ranges.map(k=>{if(k.empty){var b=k.to1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(a){var c=this.cm6.state.selection;this.virtualSelection=ee.EditorSelection.create(c.ranges,c.mainIndex);for(var p=0;pqe(u,a)})},indentAuto:function(u){Le.indentSelection(u.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};I.isWordChar=function(u){return pt.test(u)};I.keys=fn;I.addClass=function(u,a){};I.rmClass=function(u,a){};I.e_preventDefault=function(u){u.preventDefault()};I.e_stop=function(u){var a,c;(a=u?.stopPropagation)===null||a===void 0||a.call(u),(c=u?.preventDefault)===null||c===void 0||c.call(u)};I.lookupKey=function(a,c,p){var y=I.keys[a];!y&&/^Arrow/.test(a)&&(y=I.keys[a.slice(5)]),y&&p(y)};I.on=tr;I.off=rr;I.signal=nr;I.findMatchingTag=gn;I.findEnclosingTag=yn;I.keyName=void 0;function ir(u,a,c){var p=document.createElement("div");return p.appendChild(a),p}function or(u,a){u.state.currentNotificationClose&&u.state.currentNotificationClose(),u.state.currentNotificationClose=a}function cn(u,a,c){or(u,x);var p=ir(u,a,c&&c.bottom),y=!1,k,b=c&&typeof c.duration<"u"?c.duration:5e3;function x(){y||(y=!0,clearTimeout(k),p.remove(),sr(u,p))}return p.onclick=function(L){L.preventDefault(),x()},ar(u,p),b&&(k=setTimeout(x,b)),x}function ar(u,a){var c=u.state.dialog;u.state.dialog=a,a.style.flex="1",a&&c!==a&&(c&&c.contains(document.activeElement)&&u.focus(),c&&c.parentElement?c.parentElement.replaceChild(a,c):c&&c.remove(),I.signal(u,"dialog"))}function sr(u,a){u.state.dialog==a&&(u.state.dialog=null,I.signal(u,"dialog"))}function hn(u,a,c,p){p||(p={}),or(u,void 0);var y=ir(u,a,p.bottom),k=!1;ar(u,y);function b(L){if(typeof L=="string")x.value=L;else{if(k)return;k=!0,sr(u,y),u.state.dialog||u.focus(),p.onClose&&p.onClose(y)}}var x=y.getElementsByTagName("input")[0];return x&&(p.value&&(x.value=p.value,p.selectValueOnOpen!==!1&&x.select()),p.onInput&&I.on(x,"input",function(L){p.onInput(L,x.value,b)}),p.onKeyUp&&I.on(x,"keyup",function(L){p.onKeyUp(L,x.value,b)}),I.on(x,"keydown",function(L){p&&p.onKeyDown&&p.onKeyDown(L,x.value,b)||(L.keyCode==13&&c&&c(x.value),(L.keyCode==27||p.closeOnEnter!==!1&&L.keyCode==13)&&(x.blur(),I.e_stop(L),b()))}),p.closeOnBlur!==!1&&I.on(x,"blur",function(){setTimeout(function(){document.activeElement!==x&&b()})}),x.focus()),b}var dn={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function pn(u){return u&&u.bracketRegex||/[(){}[\]]/}function vn(u,a,c,p,y){for(var k=y&&y.maxScanLineLength||1e4,b=y&&y.maxScanLines||1e3,x=[],L=pn(y),F=c>0?Math.min(a.line+b,u.lastLine()+1):Math.max(u.firstLine()-1,a.line-b),D=a.line;D!=F;D+=c){var H=u.getLine(D);if(H){var j=c>0?0:H.length-1,B=c>0?H.length:-1;if(!(H.length>k))for(D==a.line&&(j=a.ch-(c<0?1:0));j!=B;j+=c){var _=H.charAt(j);if(L.test(_)){var Q=dn[_];if(Q&&Q.charAt(1)==">"==c>0)x.push(_);else if(x.length)x.pop();else return{pos:new be(D,j),ch:_}}}}}return D-c==(c>0?u.lastLine():u.firstLine())?!1:null}function gn(u,a){return null}function yn(u,a){var c,p,y=u.cm6.state,k=u.indexFromPos(a);if(kp){var L=_(x,p,5);if(L){var F=(c=/^\s*/.exec(x))===null||c===void 0?void 0:c[0];u.replaceRange(` `+F,new be(k,L.start),new be(k,L.end))}b++}else if(y&&/\S/.test(x)&&k!=b){var D=u.getLine(k+1);if(D&&/\S/.test(D)){var H=x.replace(/\s+$/,""),j=D.replace(/^\s+/,""),B=H+" "+j,L=_(B,p,5);L&&L.start>H.length||B.lengthJ)return{start:le.index,end:le.index+le[2].length};if(de&&de[2])return me=W+de[2].length,{start:me,end:me+de[3].length}}}}let vt=ln.getDrawSelectionConfig||function(){let u={cursorBlinkRate:1200};return function(){return u}}();class kn{constructor(a,c,p,y,k,b,x,L,F,D){this.left=a,this.top=c,this.height=p,this.fontFamily=y,this.fontSize=k,this.fontWeight=b,this.color=x,this.className=L,this.letter=F,this.partial=D}draw(){let a=document.createElement("div");return a.className=this.className,this.adjust(a),a}adjust(a){a.style.left=this.left+"px",a.style.top=this.top+"px",a.style.height=this.height+"px",a.style.lineHeight=this.height+"px",a.style.fontFamily=this.fontFamily,a.style.fontSize=this.fontSize,a.style.fontWeight=this.fontWeight,a.style.color=this.partial?"transparent":this.color,a.className=this.className,a.textContent=this.letter}eq(a){return this.left==a.left&&this.top==a.top&&this.height==a.height&&this.fontFamily==a.fontFamily&&this.fontSize==a.fontSize&&this.fontWeight==a.fontWeight&&this.color==a.color&&this.className==a.className&&this.letter==a.letter}}class wn{constructor(a,c){this.view=a,this.rangePieces=[],this.cursors=[],this.cm=c,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=a.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),a.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let c=vt(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=c+"ms"}update(a){(a.selectionSet||a.geometryChanged||a.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),Sn(a)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:a}=this.view,c=[];for(let p of a.selection.ranges){let y=p==a.selection.main,k=Ln(this.cm,this.view,p,y);k&&c.push(k)}return{cursors:c}}drawSel({cursors:a}){if(a.length!=this.cursors.length||a.some((c,p)=>!c.eq(this.cursors[p]))){let c=this.cursorLayer.children;if(c.length!==a.length){this.cursorLayer.textContent="";for(const p of a)this.cursorLayer.appendChild(p.draw())}else a.forEach((p,y)=>p.adjust(c[y]));this.cursors=a}}destroy(){this.cursorLayer.remove()}}function Sn(u){return vt(u.startState)!=vt(u.state)}const xn={".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}},Mn=ee.Prec.highest(Y.EditorView.theme(xn));function bn(u){let a=u.scrollDOM.getBoundingClientRect();return{left:(u.textDirection==Y.Direction.LTR?a.left:a.right-u.scrollDOM.clientWidth)-u.scrollDOM.scrollLeft*u.scaleX,top:a.top-u.scrollDOM.scrollTop*u.scaleY}}function Ln(u,a,c,p){var y,k,b,x;let L=c.head,F=!1,D=1,H=u.state.vim;if(H&&(!H.insertMode||u.state.overwrite)){if(F=!0,H.visualBlock&&!p)return null;c.anchor1&&(L--,B=a.state.sliceDoc(L,L+1));let _=a.coordsAtPos(L,1);if(!_)return null;let Q=bn(a),W=a.domAtPos(L),J=W?W.node:a.contentDOM;for(J instanceof Text&&W.offset>=J.data.length&&!((y=J.parentElement)===null||y===void 0)&&y.nextSibling&&(J=(k=J.parentElement)===null||k===void 0?void 0:k.nextSibling,W={node:J,offset:0});W&&W.node instanceof HTMLElement;)J=W.node,W={node:W.node.childNodes[W.offset],offset:0};if(!(J instanceof HTMLElement)){if(!J.parentNode)return null;J=J.parentNode}let ae=getComputedStyle(J),se=_.left,de=(x=(b=a).coordsForChar)===null||x===void 0?void 0:x.call(b,L);if(de&&(se=de.left),!B||B==` `||B=="\r")B=" ";else if(B==" "){B=" ";var j=a.coordsAtPos(L+1,-1);j&&(se=j.left-(j.left-_.left)/parseInt(ae.tabSize))}else/[\uD800-\uDBFF]/.test(B)&&L{a.state.vim&&(a.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",c=>{a.state.vim&&(a.state.vim.mode=c.mode,c.subMode&&(a.state.vim.mode+=" block"),a.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():u.dispatch({effects:lr.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=c=>{Ne.handleKey(this.cm,"","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(u){var a;if((u.viewportChanged||u.docChanged)&&this.query&&this.highlight(this.query),u.docChanged&&this.cm.onChange(u),u.selectionSet&&this.cm.onSelectionChange(),u.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),u.transactions){for(let c of u.transactions)for(let p of c.effects)if(p.is(Je.setSearchQuery))if(!((a=p.value)===null||a===void 0?void 0:a.forVim))this.highlight(null);else{let k=p.value.create();this.highlight(k)}}this.blockCursor.update(u)}updateClass(){const u=this.cm.state;!u.vim||u.vim.insertMode&&!u.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let u=this.cm.state.statusbar,a=this.cm.state.vim;if(!u||!a)return;let c=this.cm.state.dialog;if(c)c.parentElement!=u&&(u.textContent="",u.appendChild(c));else{u.textContent="";var p=(a.mode||"normal").toUpperCase();a.insertModeReturn&&(p+="(C-O)"),this.statusButton.textContent=`--${p}--`,u.appendChild(this.statusButton),u.appendChild(this.spacer)}this.dom.textContent=a.status,u.appendChild(this.dom)}destroy(){Ne.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(u){if(this.query=u,!u)return this.decorations=Y.Decoration.none;let{view:a}=this,c=new ee.RangeSetBuilder;for(let p=0,y=a.visibleRanges,k=y.length;py[p+1].from-2*Tn;)x=y[++p].to;u.highlight(a.state,b,x,(L,F)=>{c.add(L,F,In)})}return this.decorations=c.finish()}handleKey(u,a){const c=this.cm;let p=c.state.vim;if(!p)return;const y=Ne.vimKeyFromEvent(u,p);if(I.signal(this.cm,"inputEvent",{type:"handleKey",key:y}),!y)return;if(y==""&&!p.insertMode&&!p.visualMode&&this.query){const x=p.searchState_;x&&(c.removeOverlay(x.getOverlay()),x.setOverlay(null))}if(y===""&&!I.isMac&&c.somethingSelected())return this.waitForCopy=!0,!0;p.status=(p.status||"")+y;let b=Ne.multiSelectHandleKey(c,y,"user");return p=Ne.maybeInitVimState_(c),!b&&p.insertMode&&c.state.overwrite&&(u.key&&u.key.length==1&&!/\n/.test(u.key)?(b=!0,c.overWriteSelection(u.key)):u.key=="Backspace"&&(b=!0,I.commands.cursorCharLeft(c))),b&&(I.signal(this.cm,"vim-keypress",y),u.preventDefault(),u.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!b}},{eventHandlers:{copy:function(u,a){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var c=this.cm,p=c.state.vim;p&&(p.insertMode?c.setSelection(c.getCursor(),c.getCursor()):c.operation(()=>{c.curOp&&(c.curOp.isVimOp=!0),Ne.handleKey(c,"","user")}))}))},compositionstart:function(u,a){this.useNextTextInput=!0,I.signal(this.cm,"inputEvent",u)},compositionupdate:function(u,a){I.signal(this.cm,"inputEvent",u)},compositionend:function(u,a){I.signal(this.cm,"inputEvent",u)},keypress:function(u,a){I.signal(this.cm,"inputEvent",u),this.lastKeydown=="Dead"&&this.handleKey(u,a)},keydown:function(u,a){I.signal(this.cm,"inputEvent",u),this.lastKeydown=u.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(u,a))}},provide:()=>[Y.EditorView.inputHandler.of((u,a,c,p)=>{var y,k,b=Dn(u);if(!b)return!1;var x=(y=b.state)===null||y===void 0?void 0:y.vim,L=b.state.vimPlugin;if(x&&!x.insertMode&&!(!((k=b.curOp)===null||k===void 0)&&k.isVimOp)){if(p==="\0\0")return!0;if(I.signal(b,"inputEvent",{type:"text",text:p,from:a,to:c}),p.length==1&&L.useNextTextInput){if(x.expectLiteralNext&&u.composing)return L.compositionText=p,!1;if(L.compositionText){var F=L.compositionText;L.compositionText="";var D=u.state.selection.main.head,H=u.state.sliceDoc(D-F.length,D);if(F===H){var j=b.getCursor();b.replaceRange("",b.posFromIndex(D-F.length),j)}}return L.handleKey({key:p,preventDefault:()=>{},stopPropagation:()=>{}}),Rn(u),!0}}return!1})],decorations:u=>u.decorations});function Rn(u){var a=u.scrollDOM.parentElement;if(a){if(En){u.contentDOM.textContent="\0\0",u.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var c=u.scrollDOM.nextSibling,p=window.getSelection(),y=p&&{anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset};u.scrollDOM.remove(),a.insertBefore(u.scrollDOM,c);try{y&&p&&(p.setPosition(y.anchorNode,y.anchorOffset),y.focusNode&&p.extend(y.focusNode,y.focusOffset))}catch(k){console.error(k)}u.focus(),u.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const In=Y.Decoration.mark({class:"cm-searchMatch"}),lr=ee.StateEffect.define(),Bn=ee.StateField.define({create:()=>!1,update(u,a){for(let c of a.effects)c.is(lr)&&(u=c.value);return u},provide:u=>Y.showPanel.from(u,a=>a?Nn:null)});function Nn(u){let a=document.createElement("div");a.className="cm-vim-panel";let c=u.cm;return c.state.dialog&&a.appendChild(c.state.dialog),{top:!1,dom:a}}function Pn(u){let a=document.createElement("div");a.className="cm-vim-panel";let c=u.cm;return c.state.statusbar=a,c.state.vimPlugin.updateStatus(),{dom:a}}function Kn(u={}){return[An,On,Mn,u.status?Y.showPanel.of(Pn):Bn]}function Dn(u){return u.cm||null}const _n=Y.EditorView.baseTheme({".cm-vim-panel":{paddingTop:"3px",paddingBottom:"3px"},".cm-vim-panel *":{fontFamily:"monospace",fontSize:"14px"}});er.MarkEdit.addExtension([_n,ee.Prec.highest(Kn({status:!0}))]);er.MarkEdit.onEditorReady(({dom:u})=>{const a=u.querySelector(".cm-panels-bottom");if(a===null)return;new MutationObserver(()=>{const p=Array.from(a.querySelectorAll("span")).find(y=>y.style.top==="1px");p&&(p.style.display="none")}).observe(a,{attributes:!0,childList:!0,subtree:!0})});