texlite 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +29 -6
- package/README.md +6 -3
- package/README.zh-CN.md +6 -2
- package/dist/client/assets/AdminUsers-huwQK7Ly.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-C5C3sPdw.js +1 -0
- package/dist/client/assets/Dashboard-DtHSc55D.js +2 -0
- package/dist/client/assets/{GitDialog-CTWAU8q6.js → GitDialog-BI7QIMsh.js} +1 -1
- package/dist/client/assets/{HistoryDialog-Mo4p8HEg.js → HistoryDialog-DA7O9aF2.js} +1 -1
- package/dist/client/assets/LatexEditor-BYWWx5Km.js +138 -0
- package/dist/client/assets/{PdfPreview-BUpELZd-.js → PdfPreview-mO9WS01q.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-B0q_r5dX.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-CpjkXZTz.js → ProjectNavigationDialogs-DwWYbB1A.js} +1 -1
- package/dist/client/assets/ProjectSettings-BpPFgdoj.js +1 -0
- package/dist/client/assets/ProjectWorkspace-CI2zKon5.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-9FWlc3Rb.js → SelectionHistoryDialog-pWMI5izu.js} +2 -2
- package/dist/client/assets/SystemMetricsDialog-BmlO7oNg.js +1 -0
- package/dist/client/assets/{TagManagementDialog-BHIA0vEA.js → TagManagementDialog-h4Ves4FR.js} +1 -1
- package/dist/client/assets/{WordCountDialog-DFIWvLrP.js → WordCountDialog-DlBSP4y7.js} +1 -1
- package/dist/client/assets/check-BAdi_Lxq.js +1 -0
- package/dist/client/assets/{editor-3rgn4IYh.js → editor-DZS7-wrd.js} +1 -1
- package/dist/client/assets/{hard-drive-B-NSDVVA.js → hard-drive-DP2OHKMC.js} +1 -1
- package/dist/client/assets/index-CBrIrzgg.css +1 -0
- package/dist/client/assets/{index-CNTGCh7t.js → index-i5IY_PMw.js} +1 -1
- package/dist/client/assets/index-teah8iB2.js +12 -0
- package/dist/client/assets/{key-round-BjL9H8-H.js → key-round-D8sCqL2b.js} +1 -1
- package/dist/client/assets/{minimize-2-DDCq8c49.js → minimize-2-6tf519Ts.js} +1 -1
- package/dist/client/assets/{minus-DgKZCT9F.js → minus-CqvESp9M.js} +1 -1
- package/dist/client/assets/{plus-CezUzSIZ.js → plus-DIrweesj.js} +1 -1
- package/dist/client/assets/{refresh-cw-CDFNL-qu.js → refresh-cw-BDcwKu_d.js} +1 -1
- package/dist/client/assets/{search-CrDJjHoj.js → search-C9_Jyrnx.js} +1 -1
- package/dist/client/assets/{sigma-DOcJr7VG.js → sigma-p9-fBP0d.js} +1 -1
- package/dist/client/assets/{spellCheck-BgWyesvf.js → spellCheck-Y0RlmXbl.js} +1 -1
- package/dist/client/assets/{tags-BedQ75lh.js → tags-DjF3z21M.js} +1 -1
- package/dist/client/assets/{type-glZNdzZR.js → type-CNrDJnzR.js} +1 -1
- package/dist/client/assets/{user-plus-gQ6q5Nom.js → user-plus-C7exNawX.js} +1 -1
- package/dist/client/assets/x-BEVz0wdw.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/collaboration.js +6 -19
- package/dist/server/db.js +91 -10
- package/dist/server/latexDocumentGraph.js +127 -16
- package/dist/server/projectOutline.js +103 -91
- package/dist/server/projectReferences.js +1 -1
- package/dist/server/routes/comments.js +10 -4
- package/dist/server/routes/projectShared.js +33 -12
- package/dist/shared/collaborationProtocol.js +31 -0
- package/dist/shared/latexDependencies.js +83 -23
- package/dist/shared/writingChecks.js +2 -2
- package/package.json +1 -1
- package/dist/client/assets/AdminUsers-Buf5ZclR.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DrKbIlD-.js +0 -1
- package/dist/client/assets/Dashboard-DLk2j3oq.js +0 -2
- package/dist/client/assets/LatexEditor-CwvakYva.js +0 -135
- package/dist/client/assets/ProjectIconPickerDialog-BiWSwDdt.js +0 -1
- package/dist/client/assets/ProjectSettings-DoxitHbX.js +0 -1
- package/dist/client/assets/ProjectWorkspace-iNqXZlsj.js +0 -29
- package/dist/client/assets/SystemMetricsDialog-24kifZO6.js +0 -1
- package/dist/client/assets/check-C3GZh6a1.js +0 -1
- package/dist/client/assets/chevron-left-l1oupvGO.js +0 -1
- package/dist/client/assets/index-CrlfruX_.css +0 -1
- package/dist/client/assets/index-DIM_KiG2.js +0 -12
- package/dist/client/assets/x-CSzFikn2.js +0 -1
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./katex-D9PXdmFF.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as ko,r as Z,j as Ke}from"./react-BVUjbTTn.js";import{s as Vr,E as fe,V as dt,D as Y,a as un,R as Co,P as jr,S as _t,b as Le,f as Oo,M as qr,m as lr,i as xo,c as So,d as wo,e as Mo,g as Eo,h as Lo,j as cr,k as xn,l as Qt,n as To,o as Ro,p as Ao,q as Po,r as No,t as Bo,u as Fo,v as Io,w as Do,x as $o,y as ct,F as Kt,A as Sn,z as _o,W as zr,L as Qo,B as Ko,C as Vo,G as jo,H as ut,I as qo,J as ye,K as Vt,N as Hr,O as oe,Q as zo,T as Wr,U as Ho,X as Ue,Y as Wo,Z as Dt,_ as Ur,$ as Uo,a0 as Xo,a1 as Nt,a2 as Zo,a3 as Yo,a4 as Jo,a5 as Go,a6 as ea,a7 as ta,a8 as na,a9 as ra,aa as ia,ab as oa,ac as aa,ad as sa,ae as la,af as ca,ag as ua,ah as fa,ai as da,aj as ha,ak as pa,al as ma,am as ga,an as va}from"./editor-3rgn4IYh.js";import{r as ur,a as yt,U as Xr,b as fn,d as dn,e as fr,m as ya,f as ba,g as an,t as Bt,h as Ft,i as jt,l as qt,j as zt,k as wn,n as ka,o as Zr,p as Ca,q as Oa}from"./ProjectWorkspace-iNqXZlsj.js";import{_ as dr}from"./index-DIM_KiG2.js";import"./check-C3GZh6a1.js";import"./x-CSzFikn2.js";import"./search-CrDJjHoj.js";import"./user-plus-gQ6q5Nom.js";import"./refresh-cw-CDFNL-qu.js";function xa(t){var n=t.Pos;function o(e,r,i){if(r.line===i.line&&r.ch>=i.ch-1){var a=e.getLine(r.line),l=a.charCodeAt(r.ch);55296<=l&&l<=55551&&(i.ch+=1)}return{start:r,end:i}}var s=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",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:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",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:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",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<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",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:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",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:"gc",type:"operator",operator:"toggleComment",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:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",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:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",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<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",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:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",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<CR>",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:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",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"}],c=Object.create(null),f=s.length,m=[{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:"put",shortName:"pu"},{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"}],v=at("");function b(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),t.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",nr),ze(e),t.on(e.getInputField(),"paste",M(e))}function S(e){e.setOption("disableInput",!1),e.off("cursorActivity",nr),t.off(e.getInputField(),"paste",M(e)),e.state.vim=null,gt&&clearTimeout(gt)}function M(e){var r=e.state.vim;return r.onPasteFn||(r.onPasteFn=function(){r.insertMode||(e.setCursor(se(e.getCursor(),0,1)),tt.enterInsertMode(e,{},r))}),r.onPasteFn}var R=/[\d]/,A=[t.isWordChar,function(e){return e&&!t.isWordChar(e)&&!/\s/.test(e)}],E=[function(e){return/\S/.test(e)}],T=["<",">"],D=["-",'"',".",":","_","/","+"],z=/^\w$/,W=/^[A-Z]$/;try{W=new RegExp("^[\\p{Lu}]$","u")}catch{}function ie(e,r){return r>=e.firstLine()&&r<=e.lastLine()}function Q(e){return/^[a-z]$/.test(e)}function de(e){return"()[]{}".indexOf(e)!=-1}function he(e){return R.test(e)}function J(e){return W.test(e)}function ce(e){return/^\s*$/.test(e)}function Ie(e){return".?!".indexOf(e)!=-1}function ot(e,r){for(var i=0;i<r.length;i++)if(r[i]==e)return!0;return!1}var Te={};function qe(e,r,i,a,l){if(r===void 0&&!l)throw Error("defaultValue is required unless callback is provided");if(i||(i="string"),Te[e]={type:i,defaultValue:r,callback:l},a)for(var u=0;u<a.length;u++)Te[a[u]]=Te[e];r&&Ye(e,r)}function Ye(e,r,i,a){var l=Te[e];a=a||{};var u=a.scope;if(!l)return new Error("Unknown option: "+e);if(l.type=="boolean"){if(r&&r!==!0)return new Error("Invalid argument: "+e+"="+r);r!==!1&&(r=!0)}l.callback?(u!=="local"&&l.callback(r,void 0),u!=="global"&&i&&l.callback(r,i)):(u!=="local"&&(l.value=l.type=="boolean"?!!r:r),u!=="global"&&i&&(i.state.vim.options[e]={value:r}))}function be(e,r,i){var a=Te[e];i=i||{};var l=i.scope;if(!a)return new Error("Unknown option: "+e);if(a.callback){let u=r&&a.callback(void 0,r);return l!=="global"&&u!==void 0?u:l!=="local"?a.callback():void 0}else return(l!=="global"&&r&&r.state.vim.options[e]||l!=="local"&&a||{}).value}qe("filetype",void 0,"string",["ft"],function(e,r){if(r!==void 0)if(e===void 0){let i=r.getOption("mode");return i=="null"?"":i}else{let i=e==""?"null":e;r.setOption("mode",i)}}),qe("textwidth",80,"number",["tw"],function(e,r){if(r!==void 0)if(e===void 0){var i=r.getOption("textwidth");return i}else{var a=Math.round(e);a>1&&r.setOption("textwidth",a)}});var Mt=function(){var e=100,r=-1,i=0,a=0,l=new Array(e);function u(p,g,y){var C=r%e,O=l[C];function x(w){var L=++r%e,F=l[L];F&&F.clear(),l[L]=p.setBookmark(w)}if(O){var k=O.find();k&&!Ae(k,g)&&x(g)}else x(g);x(y),i=r,a=r-e+1,a<0&&(a=0)}function d(p,g){r+=g,r>i?r=i:r<a&&(r=a);var y=l[(e+r)%e];if(y&&!y.find()){var C=g>0?1:-1,O,x=p.getCursor();do if(r+=C,y=l[(e+r)%e],y&&(O=y.find())&&!Ae(x,O))break;while(r<i&&r>a)}return y}function h(p,g){var y=r,C=d(p,g);return r=y,C&&C.find()}return{cachedCursor:void 0,add:u,find:h,move:d}},ht=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Et{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ht()}exitMacroRecordMode(){var r=P.macroModeState;r.onRecordingDone&&r.onRecordingDone(),r.onRecordingDone=void 0,r.isRecording=!1}enterMacroRecordMode(r,i){var a=P.registerController.getRegister(i);if(a){if(a.clear(),this.latestRegister=i,r.openDialog){var l=Be("span",{class:"cm-vim-message"},"recording @"+i);this.onRecordingDone=r.openDialog(l,function(){},{bottom:!0})}this.isRecording=!0}}}function ze(e){return e.state.vim||(e.state.vim={inputState:new Lt,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 n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var P;function pt(){P={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:Mt(),macroModeState:new Et,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Ti({}),searchHistoryController:new Pn,exCommandHistoryController:new Pn};for(var e in Te){var r=Te[e];r.value=r.defaultValue}}class He{constructor(r,i){this.keyName=r,this.key=i.key,this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.shiftKey=i.shiftKey}}var Je,pe={enterVimMode:b,leaveVimMode:S,buildKeyMap:function(){},getRegisterController:function(){return P.registerController},resetVimGlobalState_:pt,getVimGlobalState_:function(){return P},maybeInitVimState_:ze,suppressErrorLogging:!1,InsertModeKey:He,map:function(e,r,i){Se.map(e,r,i)},unmap:function(e,r){return Se.unmap(e,r)},noremap:function(e,r,i){Se.map(e,r,i,!0)},mapclear:function(e){var r=s.length,i=f,a=s.slice(0,r-i);if(s=s.slice(r-i),e)for(var l=a.length-1;l>=0;l--){var u=a[l];if(e!==u.context)if(u.context)this._mapCommand(u);else{var d=["normal","insert","visual"];for(var h in d)if(d[h]!==e){var p=Object.assign({},u);p.context=d[h],this._mapCommand(p)}}}},langmap:Ge,vimKeyFromEvent:re,setOption:Ye,getOption:be,defineOption:qe,defineEx:function(e,r,i){if(!r)r=e;else if(e.indexOf(r)!==0)throw new Error('(Vim.defineEx) "'+r+'" is not a prefix of "'+e+'", command not registered');er[e]=i,Se.commandMap_[r]={name:e,shortName:r,type:"api"}},handleKey:function(e,r,i){var a=this.findKey(e,r,i);if(typeof a=="function")return a()},multiSelectHandleKey:bo,findKey:function(e,r,i){var a=ze(e),l=e;function u(){var y=P.macroModeState;if(y.isRecording){if(r=="q")return y.exitMacroRecordMode(),ue(l),!0;i!="mapping"&&go(y,r)}}function d(){if(r=="<Esc>"){if(a.visualMode)_e(l);else if(a.insertMode)Ze(l);else return;return ue(l),!0}}function h(){if(d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join(""),C=r.length==1,O=et.matchCommand(y,s,a.inputState,"insert"),x=a.inputState.changeQueue;if(O.type=="none")return ue(l),!1;if(O.type=="partial"){if(O.expectLiteralNext&&(a.expectLiteralNext=!0),Je&&window.clearTimeout(Je),Je=C&&window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer.length&&ue(l)},be("insertModeEscKeysTimeout")),C){var k=l.listSelections();(!x||x.removed.length!=k.length)&&(x=a.inputState.changeQueue=new Tt),x.inserted+=r;for(var w=0;w<k.length;w++){var L=xe(k[w].anchor,k[w].head),F=Xe(k[w].anchor,k[w].head),N=l.getRange(L,l.state.overwrite?se(F,0,1):F);x.removed[w]=(x.removed[w]||"")+N}}return!C}else O.type=="full"&&(a.inputState.keyBuffer.length=0);if(a.expectLiteralNext=!1,Je&&window.clearTimeout(Je),O.command&&x){for(var k=l.listSelections(),w=0;w<k.length;w++){var B=k[w].head;l.replaceRange(x.removed[w]||"",se(B,0,-x.inserted.length),B,"+input")}P.macroModeState.lastInsertModeChanges.changes.pop()}return O.command||ue(l),O.command}function p(){if(u()||d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(y))return!0;var C=/^(\d*)(.*)$/.exec(y);if(!C)return ue(l),!1;var O=a.visualMode?"visual":"normal",x=C[2]||C[1];a.inputState.operatorShortcut&&a.inputState.operatorShortcut.slice(-1)==x&&(x=a.inputState.operatorShortcut);var k=et.matchCommand(x,s,a.inputState,O);return k.type=="none"?(ue(l),!1):k.type=="partial"?(k.expectLiteralNext&&(a.expectLiteralNext=!0),!0):k.type=="clear"?(ue(l),!0):(a.expectLiteralNext=!1,a.inputState.keyBuffer.length=0,C=/^(\d*)(.*)$/.exec(y),C&&C[1]&&C[1]!="0"&&a.inputState.pushRepeatDigit(C[1]),k.command)}var g=a.insertMode?h():p();if(g===!1)return!a.insertMode&&(r.length===1||t.isMac&&/<A-.>/.test(r))?function(){return!0}:void 0;if(g===!0)return function(){return!0};if(g)return function(){return l.operation(function(){l.curOp.isVimOp=!0;try{if(typeof g!="object")return;g.type=="keyToKey"?X(l,g.toKeys,g):et.processCommand(l,a,g)}catch(y){throw l.state.vim=void 0,ze(l),pe.suppressErrorLogging||console.log(y),y}return!0})}},handleEx:function(e,r){Se.processCommand(e,r)},defineMotion:Ri,defineAction:Pi,defineOperator:Ai,mapCommand:po,_mapCommand:tn,defineRegister:Li,exitVisualMode:_e,exitInsertMode:Ze},ke=[],Re=!1,ne;function I(e){if(!ne)throw new Error("No prompt to send key to");if(e[0]=="<"){var r=e.toLowerCase().slice(1,-1),i=r.split("-");if(r=i.pop()||"",r=="lt")e="<";else if(r=="space")e=" ";else if(r=="cr")e=`
|
|
3
|
-
`;else if(U[r]){var a=ne.value||"",l={key:U[r],target:{value:a,selectionEnd:a.length,selectionStart:a.length}};ne.onKeyDown&&ne.onKeyDown(l,ne.value,d),ne&&ne.onKeyUp&&ne.onKeyUp(l,ne.value,d);return}}if(e==`
|
|
4
|
-
`){var u=ne;ne=null,u.onClose&&u.onClose(u.value)}else ne.value=(ne.value||"")+e;function d(h){ne&&(typeof h=="string"?ne.value=h:ne=null)}}function X(e,r,i){var a=Re;if(i){if(ke.indexOf(i)!=-1)return;ke.push(i),Re=i.noremap!=!1}try{for(var l=ze(e),u=/<(?:[CSMA]-)*\w+>|./gi,d;d=u.exec(r);){var h=d[0],p=l.insertMode;if(ne){I(h);continue}var g=pe.handleKey(e,h,"mapping");if(!g&&p&&l.insertMode){if(h[0]=="<"){var y=h.toLowerCase().slice(1,-1),C=y.split("-");if(y=C.pop()||"",y=="lt")h="<";else if(y=="space")h=" ";else if(y=="cr")h=`
|
|
5
|
-
`;else if(U.hasOwnProperty(y)){h=U[y],ar(e,h);continue}else h=h[0],u.lastIndex=d.index+1}e.replaceSelection(h)}}}finally{if(ke.pop(),Re=ke.length?a:!1,!ke.length&&ne){var O=ne;ne=null,At(e,O)}}}var G={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},$={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},U={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(G)).forEach(function(e){U[(G[e]||"").toLowerCase()]=U[e.toLowerCase()]=e});function re(e,r){var i=e.key;if(!$[i]){i.length>1&&i[0]=="n"&&(i=i.replace("Numpad","")),i=G[i]||i;var a="";if(e.ctrlKey&&(a+="C-"),e.altKey&&(a+="A-"),e.metaKey&&(a+="M-"),t.isMac&&a=="A-"&&i.length==1&&(a=a.slice(2)),(a||i.length>1)&&e.shiftKey&&(a+="S-"),r&&!r.expectLiteralNext&&i.length==1){if(v.keymap&&i in v.keymap)(v.remapCtrl!=!1||!a)&&(i=v.keymap[i]);else if(i.charCodeAt(0)>128&&!c[i]){var l=e.code?.slice(-1)||"";e.shiftKey||(l=l.toLowerCase()),l&&(i=l,!a&&e.altKey&&(a="A-"))}}return a+=i,a.length>1&&(a="<"+a+">"),a}}function Ge(e,r){v.string!==e&&(v=at(e)),v.remapCtrl=r}function at(e){let r={};if(!e)return{keymap:r,string:""};function i(a){return a.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(a=>{if(!a)return;const l=a.split(/((?:[^\\;]|\\.)+);/);if(l.length==3){const u=i(l[1]),d=i(l[2]);if(u.length!==d.length)return;for(let h=0;h<u.length;++h)r[u[h]]=d[h]}else if(l.length==1){const u=i(a);if(u.length%2!==0)return;for(let d=0;d<u.length;d+=2)r[u[d]]=u[d+1]}}),{keymap:r,string:e}}qe("langmap",void 0,"string",["lmap"],function(e,r){if(e===void 0)return v.string;Ge(e)});class Lt{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(r){this.operator?this.motionRepeat=this.motionRepeat.concat(r):this.prefixRepeat=this.prefixRepeat.concat(r)}getRepeat(){var r=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(r=1,this.prefixRepeat.length>0&&(r*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(r*=parseInt(this.motionRepeat.join(""),10))),r}}function ue(e,r){e.state.vim.inputState=new Lt,e.state.vim.expectLiteralNext=!1,t.signal(e,"vim-command-done",r)}function Tt(){this.removed=[],this.inserted=""}class De{constructor(r,i,a){this.clear(),this.keyBuffer=[r||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!i,this.blockwise=!!a}setText(r,i,a){this.keyBuffer=[r||""],this.linewise=!!i,this.blockwise=!!a}pushText(r,i){i&&(this.linewise||this.keyBuffer.push(`
|
|
6
|
-
`),this.linewise=!0),this.keyBuffer.push(r)}pushInsertModeChanges(r){this.insertModeChanges.push(ht(r))}pushSearchQuery(r){this.searchQueries.push(r)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function Li(e,r){var i=P.registerController.registers;if(!e||e.length!=1)throw Error("Register name must be 1 character");if(i[e])throw Error("Register already defined "+e);i[e]=r,D.push(e)}class Ti{constructor(r){this.registers=r,this.unnamedRegister=r['"']=new De,r["."]=new De,r[":"]=new De,r["/"]=new De,r["+"]=new De}pushText(r,i,a,l,u){if(r!=="_"){l&&a.charAt(a.length-1)!==`
|
|
7
|
-
`&&(a+=`
|
|
8
|
-
`);var d=this.isValidRegister(r)?this.getRegister(r):null;if(!d||!r){switch(i){case"yank":this.registers[0]=new De(a,l,u);break;case"delete":case"change":a.indexOf(`
|
|
9
|
-
`)==-1?this.registers["-"]=new De(a,l):(this.shiftNumericRegisters_(),this.registers[1]=new De(a,l));break}this.unnamedRegister.setText(a,l,u);return}var h=J(r);h?d.pushText(a,l):d.setText(a,l,u),r==="+"&&navigator.clipboard.writeText(a),this.unnamedRegister.setText(d.toString(),l)}}getRegister(r){return this.isValidRegister(r)?(r=r.toLowerCase(),this.registers[r]||(this.registers[r]=new De),this.registers[r]):this.unnamedRegister}isValidRegister(r){return r&&(ot(r,D)||z.test(r))}shiftNumericRegisters_(){for(var r=9;r>=2;r--)this.registers[r]=this.getRegister(""+(r-1))}}class Pn{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(r,i){var a=this.historyBuffer,l=i?-1:1;this.initialPrefix===null&&(this.initialPrefix=r);for(var u=this.iterator+l;i?u>=0:u<a.length;u+=l)for(var d=a[u],h=0;h<=d.length;h++)if(this.initialPrefix==d.substring(0,h))return this.iterator=u,d;if(u>=a.length)return this.iterator=a.length,this.initialPrefix;if(u<0)return r}pushInput(r){var i=this.historyBuffer.indexOf(r);i>-1&&this.historyBuffer.splice(i,1),r.length&&this.historyBuffer.push(r)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var et={matchCommand:function(e,r,i,a){var l=Ni(e,r,a,i),u=l.full[0];if(!u)return l.partial.length?{type:"partial",expectLiteralNext:l.partial.length==1&&l.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(u.keys.slice(-11)=="<character>"||u.keys.slice(-10)=="<register>"){var d=Fi(e);if(!d||d.length>1)return{type:"clear"};i.selectedCharacter=d}return{type:"full",command:u}},processCommand:function(e,r,i){switch(r.inputState.repeatOverride=i.repeatOverride,i.type){case"motion":this.processMotion(e,r,i);break;case"operator":this.processOperator(e,r,i);break;case"operatorMotion":this.processOperatorMotion(e,r,i);break;case"action":this.processAction(e,r,i);break;case"search":this.processSearch(e,r,i);break;case"ex":case"keyToEx":this.processEx(e,r,i);break}},processMotion:function(e,r,i){r.inputState.motion=i.motion,r.inputState.motionArgs=Rt(i.motionArgs),this.evalInput(e,r)},processOperator:function(e,r,i){var a=r.inputState;if(a.operator)if(a.operator==i.operator){a.motion="expandToLine",a.motionArgs={linewise:!0,repeat:1},this.evalInput(e,r);return}else ue(e);a.operator=i.operator,a.operatorArgs=Rt(i.operatorArgs),i.keys.length>1&&(a.operatorShortcut=i.keys),i.exitVisualBlock&&(r.visualBlock=!1,st(e)),r.visualMode&&this.evalInput(e,r)},processOperatorMotion:function(e,r,i){var a=r.visualMode,l=Rt(i.operatorMotionArgs);l&&a&&l.visualLine&&(r.visualLine=!0),this.processOperator(e,r,i),a||this.processMotion(e,r,i)},processAction:function(e,r,i){var a=r.inputState,l=a.getRepeat(),u=!!l,d=Rt(i.actionArgs)||{repeat:1};a.selectedCharacter&&(d.selectedCharacter=a.selectedCharacter),i.operator&&this.processOperator(e,r,i),i.motion&&this.processMotion(e,r,i),(i.motion||i.operator)&&this.evalInput(e,r),d.repeat=l||1,d.repeatIsExplicit=u,d.registerName=a.registerName,ue(e),r.lastMotion=null,i.isEdit&&this.recordLastEdit(r,a,i),tt[i.action](e,d,r)},processSearch:function(e,r,i){if(!e.getSearchCursor)return;var a=i.searchArgs.forward,l=i.searchArgs.wholeWordOnly;Ne(e).setReversed(!a);var u=a?"/":"?",d=Ne(e).getQuery(),h=e.getScrollInfo(),p="";function g(N,B,_){P.searchHistoryController.pushInput(N),P.searchHistoryController.reset();try{mt(e,N,B,_)}catch{H(e,"Invalid regex: "+N),ue(e);return}et.processMotion(e,r,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:i.searchArgs.toJumplist}})}function y(N){e.scrollTo(h.left,h.top),g(N,!0,!0);var B=P.macroModeState;B.isRecording&&yo(B,N)}function C(){return be("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function O(N,B,_){var V=re(N),le,te;V=="<Up>"||V=="<Down>"?(le=V=="<Up>",te=N.target?N.target.selectionEnd:0,B=P.searchHistoryController.nextMatch(B,le)||"",_(B),te&&N.target&&(N.target.selectionEnd=N.target.selectionStart=Math.min(te,N.target.value.length))):V&&V!="<Left>"&&V!="<Right>"&&P.searchHistoryController.reset(),p=B,x()}function x(){var N;try{N=mt(e,p,!0,!0)}catch{}N?e.scrollIntoView(Jn(e,!a,N),30):(lt(e),e.scrollTo(h.left,h.top))}function k(N,B,_){var V=re(N);V=="<Esc>"||V=="<C-c>"||V=="<C-[>"||V=="<BS>"&&B==""?(P.searchHistoryController.pushInput(B),P.searchHistoryController.reset(),mt(e,d?.source||""),lt(e),e.scrollTo(h.left,h.top),t.e_stop(N),ue(e),_(),e.focus()):V=="<Up>"||V=="<Down>"?t.e_stop(N):V=="<C-u>"&&(t.e_stop(N),_(""))}switch(i.searchArgs.querySrc){case"prompt":var w=P.macroModeState;if(w.isPlaying){let B=w.replaySearchQueries.shift();g(B||"",!0,!1)}else At(e,{onClose:y,prefix:u,desc:Be("span",{$cursor:"pointer",onmousedown:function(B){B.preventDefault(),Ye("pcre",!be("pcre")),this.textContent=C(),x()}},C()),onKeyUp:O,onKeyDown:k});break;case"wordUnderCursor":var L=Yt(e,{noSymbol:!0}),F=!0;if(L||(L=Yt(e,{noSymbol:!1}),F=!1),!L){H(e,"No word under cursor"),ue(e);return}let N=e.getLine(L.start.line).substring(L.start.ch,L.end.ch);F&&l?N="\\b"+N+"\\b":N=Ii(N),P.jumpList.cachedCursor=e.getCursor(),e.setCursor(L.start),g(N,!0,!1);break}},processEx:function(e,r,i){function a(p){P.exCommandHistoryController.pushInput(p),P.exCommandHistoryController.reset(),Se.processCommand(e,p),e.state.vim&&ue(e),lt(e)}function l(p,g,y){var C=re(p),O,x;(C=="<Esc>"||C=="<C-c>"||C=="<C-[>"||C=="<BS>"&&g=="")&&(P.exCommandHistoryController.pushInput(g),P.exCommandHistoryController.reset(),t.e_stop(p),ue(e),lt(e),y(),e.focus()),C=="<Up>"||C=="<Down>"?(t.e_stop(p),O=C=="<Up>",x=p.target?p.target.selectionEnd:0,g=P.exCommandHistoryController.nextMatch(g,O)||"",y(g),x&&p.target&&(p.target.selectionEnd=p.target.selectionStart=Math.min(x,p.target.value.length))):C=="<C-u>"?(t.e_stop(p),y("")):C&&C!="<Left>"&&C!="<Right>"&&P.exCommandHistoryController.reset()}function u(p,g){var y=new t.StringStream(g),C={};try{if(Se.parseInput_(e,y,C),C.commandName!="s"){lt(e);return}var O=Se.matchCommand_(C.commandName);if(!O||(Se.parseCommandArgs_(y,C,O),!C.argString))return;var x=Yn(C.argString.slice(1),!0,!0);x&&Gt(e,x)}catch{}}if(i.type=="keyToEx")Se.processCommand(e,i.exArgs.input);else{var d={onClose:a,onKeyDown:l,onKeyUp:u,prefix:":"};if(r.visualMode)d.value="'<,'>",d.selectValueOnOpen=!1;else{var h=r.inputState.getRepeat();h>1&&(d.value=".,.+"+(h-1),d.selectValueOnOpen=!1)}At(e,d)}},evalInput:function(e,r){var i=r.inputState,a=i.motion,l=i.motionArgs||{repeat:1},u=i.operator,d=i.operatorArgs||{},h=i.registerName,p=r.sel,g=ee(r.visualMode?Oe(e,p.head):e.getCursor("head")),y=ee(r.visualMode?Oe(e,p.anchor):e.getCursor("anchor")),C=ee(g),O=ee(y),x,k,w;if(u&&this.recordLastEdit(r,i),i.repeatOverride!==void 0?w=i.repeatOverride:w=i.getRepeat(),w>0&&l.explicitRepeat?l.repeatIsExplicit=!0:(l.noRepeat||!l.explicitRepeat&&w===0)&&(w=1,l.repeatIsExplicit=!1),i.selectedCharacter&&(l.selectedCharacter=d.selectedCharacter=i.selectedCharacter),l.repeat=w,ue(e),a){var L=$e[a](e,g,l,r,i);if(r.lastMotion=$e[a],!L)return;if(l.toJumplist){var F=P.jumpList,N=F.cachedCursor;N?(_n(e,N,L),delete F.cachedCursor):_n(e,g,L)}L instanceof Array?(k=L[0],x=L[1]):x=L,x||(x=ee(g)),r.visualMode?(r.visualBlock&&x.ch===1/0||(x=Oe(e,x,C)),k&&(k=Oe(e,k)),k=k||O,p.anchor=k,p.head=x,st(e),We(e,r,"<",ae(k,x)?k:x),We(e,r,">",ae(k,x)?x:k)):u||(x=Oe(e,x,C),e.setCursor(x.line,x.ch))}if(u){if(d.lastSel){k=O;var B=d.lastSel,_=Math.abs(B.head.line-B.anchor.line),V=Math.abs(B.head.ch-B.anchor.ch);B.visualLine?x=new n(O.line+_,O.ch):B.visualBlock?x=new n(O.line+_,O.ch+V):B.head.line==B.anchor.line?x=new n(O.line,O.ch+V):x=new n(O.line+_,O.ch),r.visualMode=!0,r.visualLine=B.visualLine,r.visualBlock=B.visualBlock,p=r.sel={anchor:k,head:x},st(e)}else r.visualMode&&(d.lastSel={anchor:ee(p.anchor),head:ee(p.head),visualBlock:r.visualBlock,visualLine:r.visualLine});var le,te,me,q,K;if(r.visualMode){le=xe(p.head,p.anchor),te=Xe(p.head,p.anchor),me=r.visualLine||d.linewise,q=r.visualBlock?"block":me?"line":"char";var we=o(e,le,te);if(K=Zt(e,{anchor:we.start,head:we.end},q),me){var ge=K.ranges;if(q=="block")for(var ve=0;ve<ge.length;ve++)ge[ve].head.ch=Ce(e,ge[ve].head.line);else q=="line"&&(ge[0].head=new n(ge[0].head.line+1,0))}}else{if(le=ee(k||O),te=ee(x||C),ae(te,le)){var nt=le;le=te,te=nt}me=l.linewise||d.linewise,me?ji(e,le,te):l.forward&&Vi(e,le,te),q="char";var rn=!l.inclusive||me,we=o(e,le,te);K=Zt(e,{anchor:we.start,head:we.end},q,rn)}e.setSelections(K.ranges,K.primary),r.lastMotion=null,d.repeat=w,d.registerName=h,d.linewise=me;var on=Ut[u](e,d,K.ranges,O,x);r.visualMode&&_e(e,on!=null),on&&e.setCursor(on)}},recordLastEdit:function(e,r,i){var a=P.macroModeState;a.isPlaying||(e.lastEditInputState=r,e.lastEditActionCommand=i,a.lastInsertModeChanges.changes=[],a.lastInsertModeChanges.expectCursorActivityForChange=!1,a.lastInsertModeChanges.visualBlock=e.visualBlock?e.sel.head.line-e.sel.anchor.line:0)}},$e={moveToTopLine:function(e,r,i){var a=en(e).top+i.repeat-1;return new n(a,Qe(e.getLine(a)))},moveToMiddleLine:function(e){var r=en(e),i=Math.floor((r.top+r.bottom)*.5);return new n(i,Qe(e.getLine(i)))},moveToBottomLine:function(e,r,i){var a=en(e).bottom-i.repeat+1;return new n(a,Qe(e.getLine(a)))},expandToLine:function(e,r,i){var a=r;return new n(a.line+i.repeat-1,1/0)},findNext:function(e,r,i){var a=Ne(e),l=a.getQuery();if(l){var u=!i.forward;u=a.isReversed()?!u:u,Gt(e,l);var d=Jn(e,u,l,i.repeat);return d||H(e,"No match found "+l+(be("pcre")?" (set nopcre to use Vim regexps)":"")),d}},findAndSelectNextInclusive:function(e,r,i,a,l){var u=Ne(e),d=u.getQuery();if(d){var h=!i.forward;h=u.isReversed()?!h:h;var p=so(e,h,d,i.repeat,a);if(p){if(l.operator)return p;var g=p[0],y=new n(p[1].line,p[1].ch-1);if(a.visualMode){(a.visualLine||a.visualBlock)&&(a.visualLine=!1,a.visualBlock=!1,t.signal(e,"vim-mode-change",{mode:"visual",subMode:""}));var C=a.sel.anchor;if(C)return u.isReversed()?i.forward?[C,g]:[C,y]:i.forward?[C,y]:[C,g]}else a.visualMode=!0,a.visualLine=!1,a.visualBlock=!1,t.signal(e,"vim-mode-change",{mode:"visual",subMode:""});return h?[y,g]:[g,y]}}},goToMark:function(e,r,i,a){var l=Pt(e,a,i.selectedCharacter||"");return l?i.linewise?{line:l.line,ch:Qe(e.getLine(l.line))}:l:null},moveToOtherHighlightedEnd:function(e,r,i,a){var l=a.sel;return a.visualBlock&&i.sameLine?[Oe(e,new n(l.anchor.line,l.head.ch)),Oe(e,new n(l.head.line,l.anchor.ch))]:[l.head,l.anchor]},jumpToMark:function(e,r,i,a){for(var l=r,u=0;u<i.repeat;u++){var d=l;for(var h in a.marks)if(Q(h)){var p=a.marks[h].find(),g=i.forward?ae(p,d):ae(d,p);if(!g&&!(i.linewise&&p.line==d.line)){var y=Ae(d,l),C=i.forward?Fn(d,p,l):Fn(l,p,d);(y||C)&&(l=p)}}}return i.linewise&&(l=new n(l.line,Qe(e.getLine(l.line)))),l},moveByCharacters:function(e,r,i){var a=r,l=i.repeat,u=i.forward?a.ch+l:a.ch-l;return new n(a.line,u)},moveByLines:function(e,r,i,a){var l=r,u=l.ch;switch(a.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:u=a.lastHPos;break;default:a.lastHPos=u}var d=i.repeat+(i.repeatOffset||0),h=i.forward?l.line+d:l.line-d,p=e.firstLine(),g=e.lastLine(),y=e.findPosV(l,i.forward?d:-d,"line",a.lastHSPos),C=i.forward?y.line>h:y.line<h;return C&&(h=y.line,u=y.ch),h<p&&l.line==p?this.moveToStartOfLine(e,r,i,a):h>g&&l.line==g?jn(e,r,i,a,!0):(i.toFirstChar&&(u=Qe(e.getLine(h)),a.lastHPos=u),a.lastHSPos=e.charCoords(new n(h,u),"div").left,new n(h,u))},moveByDisplayLines:function(e,r,i,a){var l=r;switch(a.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:a.lastHSPos=e.charCoords(l,"div").left}for(var u=Math.round(i.repeat),d=0;d<u;d++){var h=e.findPosV(l,i.forward?1:-1,"line",a.lastHSPos);if(h.hitSide)break;l=h}return l!=r&&(a.lastHPos=l.ch),l},moveByPage:function(e,r,i){var a=r,l=i.repeat;return e.findPosV(a,i.forward?l:-l,"page")},moveByParagraph:function(e,r,i){var a=i.forward?1:-1;return qn(e,r,i.repeat,a).start},moveBySentence:function(e,r,i){var a=i.forward?1:-1;return Zi(e,r,i.repeat,a)},moveByScroll:function(e,r,i,a){var l=e.getScrollInfo(),u=null,d=i.repeat;d||(d=l.clientHeight/(2*e.defaultTextHeight()));var h=e.charCoords(r,"local");if(i.repeat=d,u=$e.moveByDisplayLines(e,r,i,a),!u)return null;var p=e.charCoords(u,"local");return e.scrollTo(null,l.top+p.top-h.top),u},moveByWords:function(e,r,i){return Wi(e,r,i.repeat,!!i.forward,!!i.wordEnd,!!i.bigWord)},moveTillCharacter:function(e,r,i){var a=i.repeat,l=Jt(e,a,i.forward,i.selectedCharacter,r),u=i.forward?-1:1;return Qn(u,i),l?(l.ch+=u,l):null},moveToCharacter:function(e,r,i){var a=i.repeat;return Qn(0,i),Jt(e,a,i.forward,i.selectedCharacter,r)||r},moveToSymbol:function(e,r,i){var a=i.repeat;return i.selectedCharacter&&Hi(e,a,i.forward,i.selectedCharacter)||r},moveToColumn:function(e,r,i,a){var l=i.repeat;return a.lastHPos=l-1,a.lastHSPos=e.charCoords(r,"div").left,Ui(e,l)},moveToEol:function(e,r,i,a){return jn(e,r,i,a,!1)},moveToFirstNonWhiteSpaceCharacter:function(e,r){var i=r;return new n(i.line,Qe(e.getLine(i.line)))},moveToMatchedSymbol:function(e,r){for(var i=r,a=i.line,l=i.ch,u=e.getLine(a),d;l<u.length;l++)if(d=u.charAt(l),d&&de(d)){var h=e.getTokenTypeAt(new n(a,l+1));if(h!=="string"&&h!=="comment")break}if(l<u.length){var p=d==="<"||d===">"?/[(){}[\]<>]/:/[(){}[\]]/,g=e.findMatchingBracket(new n(a,l),{bracketRegex:p});return g.to}else return i},moveToStartOfLine:function(e,r){return new n(r.line,0)},moveToLineOrEdgeOfDocument:function(e,r,i){var a=i.forward?e.lastLine():e.firstLine();return i.repeatIsExplicit&&(a=i.repeat-e.getOption("firstLineNumber")),new n(a,Qe(e.getLine(a)))},moveToStartOfDisplayLine:function(e){return e.execCommand("goLineLeft"),e.getCursor()},moveToEndOfDisplayLine:function(e){e.execCommand("goLineRight");var r=e.getCursor();return r.sticky=="before"&&r.ch--,r},textObjectManipulation:function(e,r,i,a){var l={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},u={"'":!0,'"':!0,"`":!0},d=i.selectedCharacter||"";d=="b"?d="(":d=="B"&&(d="{");var h=!i.textObjectInner,p,g;if(l[d]){if(g=!0,p=Hn(e,r,d,h),!p){var y=e.getSearchCursor(new RegExp("\\"+d,"g"),r);y.find()&&(p=Hn(e,y.from(),d,h))}}else if(u[d])g=!0,p=Yi(e,r,d,h);else if(d==="W"||d==="w")for(var C=i.repeat||1;C-- >0;){var O=Yt(e,{inclusive:h,innerWord:!h,bigWord:d==="W",noSymbol:d==="W",multiline:!0},p&&p.end);O&&(p||(p=O),p.end=O.end)}else if(d==="p")if(p=qn(e,r,i.repeat,0,h),i.linewise=!0,a.visualMode)a.visualLine||(a.visualLine=!0);else{var x=a.inputState.operatorArgs;x&&(x.linewise=!0),p.end.line--}else if(d==="t")p=qi(e,r,h);else if(d==="s"){var k=e.getLine(r.line);r.ch>0&&Ie(k[r.ch])&&(r.ch-=1);var w=zn(e,r,i.repeat,1,h),L=zn(e,r,i.repeat,-1,h);ce(e.getLine(L.line)[L.ch])&&ce(e.getLine(w.line)[w.ch-1])&&(L={line:L.line,ch:L.ch+1}),p={start:L,end:w}}return p?e.state.vim.visualMode?Qi(e,p.start,p.end,g):[p.start,p.end]:null},repeatLastCharacterSearch:function(e,r,i){var a=P.lastCharacterSearch,l=i.repeat,u=i.forward===a.forward,d=(a.increment?1:0)*(u?-1:1);i.inclusive=!!u;var h=Jt(e,l,u,a.selectedCharacter,se(r,0,-d));return h?(h.ch+=d,h):r}};function Ri(e,r){$e[e]=r}function Nn(e,r){for(var i=[],a=0;a<r;a++)i.push(e);return i}var Ut={change:function(e,r,i){var a,l,u=e.state.vim,d=i[0].anchor,h=i[0].head;if(u.visualMode)if(r.fullLine)h.ch=Number.MAX_VALUE,h.line--,e.setSelection(d,h),l=e.getSelection(),e.replaceSelection(""),a=d;else{l=e.getSelection();var y=Nn("",i.length);e.replaceSelections(y),a=xe(i[0].head,i[0].anchor)}else{l=e.getRange(d,h);var p=u.lastEditInputState;if(p?.motion=="moveByWords"&&!ce(l)){var g=/\s+$/.exec(l);g&&p.motionArgs&&p.motionArgs.forward&&(h=se(h,0,-g[0].length),l=l.slice(0,-g[0].length))}r.linewise&&(d=new n(d.line,Qe(e.getLine(d.line))),h.line>d.line&&(h=new n(h.line-1,Number.MAX_VALUE))),e.replaceRange("",d,h),a=d}P.registerController.pushText(r.registerName,"change",l,r.linewise,i.length>1),tt.enterInsertMode(e,{head:a},e.state.vim)},delete:function(e,r,i){var a,l,u=e.state.vim;if(u.visualBlock){l=e.getSelection();var p=Nn("",i.length);e.replaceSelections(p),a=xe(i[0].head,i[0].anchor)}else{var d=i[0].anchor,h=i[0].head;r.linewise&&h.line!=e.firstLine()&&d.line==e.lastLine()&&d.line==h.line-1&&(d.line==e.firstLine()?d.ch=0:d=new n(d.line-1,Ce(e,d.line-1))),l=e.getRange(d,h),e.replaceRange("",d,h),a=d,r.linewise&&(a=$e.moveToFirstNonWhiteSpaceCharacter(e,d))}return P.registerController.pushText(r.registerName,"delete",l,r.linewise,u.visualBlock),Oe(e,a)},indent:function(e,r,i){var a=e.state.vim,l=a.visualMode&&r.repeat||1;if(a.visualBlock){for(var u=e.getOption("tabSize"),d=e.getOption("indentWithTabs")?" ":" ".repeat(u),h,p=i.length-1;p>=0;p--)if(h=xe(i[p].anchor,i[p].head),r.indentRight)e.replaceRange(d.repeat(l),h,h);else{for(var g=e.getLine(h.line),y=0,C=0;C<l;C++){var O=g[h.ch+y];if(O==" ")y++;else if(O==" "){y++;for(var x=1;x<d.length&&(O=g[h.ch+y],O===" ");x++)y++}else break}e.replaceRange("",h,se(h,0,y))}return h}else if(e.indentMore)for(var C=0;C<l;C++)r.indentRight?e.indentMore():e.indentLess();else{var k=i[0].anchor.line,w=a.visualBlock?i[i.length-1].anchor.line:i[0].head.line;r.linewise&&w--;for(var p=k;p<=w;p++)for(var C=0;C<l;C++)e.indentLine(p,r.indentRight)}return $e.moveToFirstNonWhiteSpaceCharacter(e,i[0].anchor)},indentAuto:function(e,r,i){return e.execCommand("indentAuto"),$e.moveToFirstNonWhiteSpaceCharacter(e,i[0].anchor)},hardWrap:function(e,r,i,a){if(e.hardWrap){var l=i[0].anchor.line,u=i[0].head.line;r.linewise&&u--;var d=e.hardWrap({from:l,to:u});return d>l&&r.linewise&&d--,r.keepCursor?a:new n(d,0)}},toggleComment:function(e,r,i,a,l){return e.execCommand("toggleLineComment"),l},changeCase:function(e,r,i,a,l){for(var u=e.getSelections(),d=[],h=r.toLower,p=0;p<u.length;p++){var g=u[p],y="";if(h===!0)y=g.toLowerCase();else if(h===!1)y=g.toUpperCase();else for(var C=0;C<g.length;C++){var O=g.charAt(C);y+=J(O)?O.toLowerCase():O.toUpperCase()}d.push(y)}return e.replaceSelections(d),r.shouldMoveCursor?l:!e.state.vim.visualMode&&r.linewise&&i[0].anchor.line+1==i[0].head.line?$e.moveToFirstNonWhiteSpaceCharacter(e,a):r.linewise?a:xe(i[0].anchor,i[0].head)},yank:function(e,r,i,a){var l=e.state.vim,u=e.getSelection(),d=l.visualMode?xe(l.sel.anchor,l.sel.head,i[0].head,i[0].anchor):a;P.registerController.pushText(r.registerName,"yank",u,r.linewise,l.visualBlock);var h=Math.abs(e.getCursor("end").line-e.getCursor("start").line)||1;return H(e,h+" lines yanked"+(r.registerName?' into "'+r.registerName:""),!1,1500),d},rot13:function(e,r,i,a,l){for(var u=e.getSelections(),d=[],h=0;h<u.length;h++){const p=u[h].split("").map(g=>{const y=g.charCodeAt(0);return y>=65&&y<=90?String.fromCharCode(65+(y-65+13)%26):y>=97&&y<=122?String.fromCharCode(97+(y-97+13)%26):g}).join("");d.push(p)}return e.replaceSelections(d),r.shouldMoveCursor?l:!e.state.vim.visualMode&&r.linewise&&i[0].anchor.line+1==i[0].head.line?$e.moveToFirstNonWhiteSpaceCharacter(e,a):r.linewise?a:xe(i[0].anchor,i[0].head)}};function Ai(e,r){Ut[e]=r}var tt={jumpListWalk:function(e,r,i){if(!i.visualMode){var a=r.repeat||1,l=r.forward,u=P.jumpList,d=u.move(e,l?a:-a),h=d?d.find():void 0;h=h||e.getCursor(),e.setCursor(h)}},scroll:function(e,r,i){if(!i.visualMode){var a=r.repeat||1,l=e.defaultTextHeight(),u=e.getScrollInfo().top,d=l*a,h=r.forward?u+d:u-d,p=ee(e.getCursor()),g=e.charCoords(p,"local");if(r.forward)h>g.top?(p.line+=(h-g.top)/l,p.line=Math.ceil(p.line),e.setCursor(p),g=e.charCoords(p,"local"),e.scrollTo(null,g.top)):e.scrollTo(null,h);else{var y=h+e.getScrollInfo().clientHeight;y<g.bottom?(p.line-=(g.bottom-y)/l,p.line=Math.floor(p.line),e.setCursor(p),g=e.charCoords(p,"local"),e.scrollTo(null,g.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,h)}}},scrollToCursor:function(e,r){var i=e.getCursor().line,a=e.charCoords(new n(i,0),"local"),l=e.getScrollInfo().clientHeight,u=a.top;switch(r.position){case"center":u=a.bottom-l/2;break;case"bottom":var d=new n(i,e.getLine(i).length-1),h=e.charCoords(d,"local"),p=h.bottom-u;u=u-l+p;break}e.scrollTo(null,u)},replayMacro:function(e,r,i){var a=r.selectedCharacter||"",l=r.repeat||1,u=P.macroModeState;for(a=="@"?a=u.latestRegister||"":u.latestRegister=a;l--;)mo(e,i,u,a)},enterMacroRecordMode:function(e,r){var i=P.macroModeState,a=r.selectedCharacter;P.registerController.isValidRegister(a)&&i.enterMacroRecordMode(e,a)},toggleOverwrite:function(e){e.state.overwrite?(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),t.signal(e,"vim-mode-change",{mode:"insert"})):(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),t.signal(e,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(e,r,i){if(!e.getOption("readOnly")){i.insertMode=!0,i.insertModeRepeat=r&&r.repeat||1;var a=r?r.insertAt:null,l=i.sel,u=r.head||e.getCursor("head"),d=e.listSelections().length;if(a=="eol")u=new n(u.line,Ce(e,u.line));else if(a=="bol")u=new n(u.line,0);else if(a=="charAfter"){var h=o(e,u,se(u,0,1));u=h.end}else if(a=="firstNonBlank"){var h=o(e,u,$e.moveToFirstNonWhiteSpaceCharacter(e,u));u=h.end}else if(a=="startOfSelectedArea"){if(!i.visualMode)return;i.visualBlock?(u=new n(Math.min(l.head.line,l.anchor.line),Math.min(l.head.ch,l.anchor.ch)),d=Math.abs(l.head.line-l.anchor.line)+1):l.head.line<l.anchor.line?u=l.head:u=new n(l.anchor.line,0)}else if(a=="endOfSelectedArea"){if(!i.visualMode)return;i.visualBlock?(u=new n(Math.min(l.head.line,l.anchor.line),Math.max(l.head.ch,l.anchor.ch)+1),d=Math.abs(l.head.line-l.anchor.line)+1):l.head.line>=l.anchor.line?u=se(l.head,0,1):u=new n(l.anchor.line,0)}else if(a=="inplace"){if(i.visualMode)return}else a=="lastEdit"&&(u=Gn(e)||u);e.setOption("disableInput",!1),r&&r.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),t.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),t.signal(e,"vim-mode-change",{mode:"insert"})),P.macroModeState.isPlaying||(e.on("change",tr),i.insertEnd&&i.insertEnd.clear(),i.insertEnd=e.setBookmark(u,{insertLeft:!0}),t.on(e.getInputField(),"keydown",ir)),i.visualMode&&_e(e),Dn(e,u,d)}},toggleVisualMode:function(e,r,i){var a=r.repeat,l=e.getCursor(),u;if(i.visualMode)i.visualLine!=!!r.linewise||i.visualBlock!=!!r.blockwise?(i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),st(e)):_e(e);else{i.visualMode=!0,i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,u=Oe(e,new n(l.line,l.ch+a-1));var d=o(e,l,u);i.sel={anchor:d.start,head:d.end},t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),st(e),We(e,i,"<",xe(l,u)),We(e,i,">",Xe(l,u))}},reselectLastSelection:function(e,r,i){var a=i.lastSelection;if(i.visualMode&&$n(e,i),a){var l=a.anchorMark.find(),u=a.headMark.find();if(!l||!u)return;i.sel={anchor:l,head:u},i.visualMode=!0,i.visualLine=a.visualLine,i.visualBlock=a.visualBlock,st(e),We(e,i,"<",xe(l,u)),We(e,i,">",Xe(l,u)),t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""})}},joinLines:function(e,r,i){var a,l;if(i.visualMode){if(a=e.getCursor("anchor"),l=e.getCursor("head"),ae(l,a)){var u=l;l=a,a=u}l.ch=Ce(e,l.line)-1}else{var d=Math.max(r.repeat,2);a=e.getCursor(),l=Oe(e,new n(a.line+d-1,1/0))}for(var h=0,p=a.line;p<l.line;p++){h=Ce(e,a.line);var g="",y=0;if(!r.keepSpaces){var C=e.getLine(a.line+1);y=C.search(/\S/),y==-1?y=C.length:g=" "}e.replaceRange(g,new n(a.line,h),new n(a.line+1,y))}var O=Oe(e,new n(a.line,h));i.visualMode&&_e(e,!1),e.setCursor(O)},newLineAndEnterInsertMode:function(e,r,i){i.insertMode=!0;var a=ee(e.getCursor());if(a.line===e.firstLine()&&!r.after)e.replaceRange(`
|
|
10
|
-
`,new n(e.firstLine(),0)),e.setCursor(e.firstLine(),0);else{a.line=r.after?a.line:a.line-1,a.ch=Ce(e,a.line),e.setCursor(a);var l=t.commands.newlineAndIndentContinueComment||t.commands.newlineAndIndent;l(e)}this.enterInsertMode(e,{repeat:r.repeat},i)},paste:function(e,r,i){var a=P.registerController.getRegister(r.registerName);if(r.registerName==="+")navigator.clipboard.readText().then(u=>{this.continuePaste(e,r,i,u,a)});else{var l=a.toString();this.continuePaste(e,r,i,l,a)}},continuePaste:function(e,r,i,a,l){var u=ee(e.getCursor());if(a){if(r.matchIndent){var d=e.getOption("tabSize"),h=function(ge){var ve=ge.split(" ").length-1,nt=ge.split(" ").length-1;return ve*d+nt*1},p=e.getLine(e.getCursor().line),g=h(p.match(/^\s*/)[0]),y=a.replace(/\n$/,""),C=a!==y,O=h(a.match(/^\s*/)[0]),a=y.replace(/^\s*/gm,function(ge){var ve=g+(h(ge)-O);if(ve<0)return"";if(e.getOption("indentWithTabs")){var nt=Math.floor(ve/d);return Array(nt+1).join(" ")}else return Array(ve+1).join(" ")});a+=C?`
|
|
11
|
-
`:""}r.repeat>1&&(a=Array(r.repeat+1).join(a));var x=r.linewise==null?l.linewise:r.linewise,k=l.blockwise,w=k?a.split(`
|
|
12
|
-
`):void 0;if(w){x&&w.pop();for(var L=0;L<w.length;L++)w[L]=w[L]==""?" ":w[L];u.ch+=r.after?1:0,u.ch=Math.min(Ce(e,u.line),u.ch)}else x?i.visualMode?a=i.visualLine?a.slice(0,-1):`
|
|
13
|
-
`+a.slice(0,a.length-1)+`
|
|
14
|
-
`:r.after?(a=`
|
|
15
|
-
`+a.slice(0,a.length-1),u.ch=Ce(e,u.line)):u.ch=0:u.ch+=r.after?1:0;var F;if(i.visualMode){i.lastPastedText=a;var N,B=_i(e),_=B[0],V=B[1],le=e.getSelection(),te=e.listSelections(),me=new Array(te.length).join("1").split("1");i.lastSelection&&(N=i.lastSelection.headMark.find()),P.registerController.unnamedRegister.setText(le),k?(e.replaceSelections(me),V=new n(_.line+a.length-1,_.ch),e.setCursor(_),In(e,V),e.replaceSelections(a),F=_):i.visualBlock?(e.replaceSelections(me),e.setCursor(_),e.replaceRange(a,_,_),F=_):(e.replaceRange(a,_,V),F=e.posFromIndex(e.indexFromPos(_)+a.length-1)),N&&(i.lastSelection.headMark=e.setBookmark(N)),x&&(F.ch=0)}else if(k&&w){e.setCursor(u);for(var L=0;L<w.length;L++){var q=u.line+L;q>e.lastLine()&&e.replaceRange(`
|
|
16
|
-
`,new n(q,0));var K=Ce(e,q);K<u.ch&&Di(e,q,u.ch)}e.setCursor(u),In(e,new n(u.line+w.length-1,u.ch)),e.replaceSelections(w),F=u}else if(e.replaceRange(a,u),x){var q=r.after?u.line+1:u.line;F=new n(q,Qe(e.getLine(q)))}else F=ee(u),/\n/.test(a)||(F.ch+=a.length-(r.after?1:0));i.visualMode&&_e(e,!1),e.setCursor(F)}},undo:function(e,r){e.operation(function(){Bn(e,t.commands.undo,r.repeat)(),e.setCursor(Oe(e,e.getCursor("start")))})},redo:function(e,r){Bn(e,t.commands.redo,r.repeat)()},setRegister:function(e,r,i){i.inputState.registerName=r.selectedCharacter},insertRegister:function(e,r,i){var a=r.selectedCharacter,l=P.registerController.getRegister(a),u=l&&l.toString();u&&e.replaceSelection(u)},oneNormalCommand:function(e,r,i){Ze(e,!0),i.insertModeReturn=!0,t.on(e,"vim-command-done",function a(){i.visualMode||(i.insertModeReturn&&(i.insertModeReturn=!1,i.insertMode||tt.enterInsertMode(e,{},i)),t.off(e,"vim-command-done",a))})},setMark:function(e,r,i){var a=r.selectedCharacter;a&&We(e,i,a,e.getCursor())},replace:function(e,r,i){var a=r.selectedCharacter||"",l=e.getCursor(),u,d,h=e.listSelections();if(i.visualMode)l=e.getCursor("start"),d=e.getCursor("end");else{var p=e.getLine(l.line);u=l.ch+r.repeat,u>p.length&&(u=p.length),d=new n(l.line,u)}var g=o(e,l,d);if(l=g.start,d=g.end,a==`
|
|
17
|
-
`)i.visualMode||e.replaceRange("",l,d),(t.commands.newlineAndIndentContinueComment||t.commands.newlineAndIndent)(e);else{var y=e.getRange(l,d);if(y=y.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,a),y=y.replace(/[^\n]/g,a),i.visualBlock){var C=new Array(e.getOption("tabSize")+1).join(" ");y=e.getSelection(),y=y.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,a);var O=y.replace(/\t/g,C).replace(/[^\n]/g,a).split(`
|
|
18
|
-
`);e.replaceSelections(O)}else e.replaceRange(y,l,d);i.visualMode?(l=ae(h[0].anchor,h[0].head)?h[0].anchor:h[0].head,e.setCursor(l),_e(e,!1)):e.setCursor(se(d,0,-1))}},incrementNumberToken:function(e,r){for(var i=e.getCursor(),a=e.getLine(i.line),l=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,u,d,h,p;(u=l.exec(a))!==null&&(d=u.index,h=d+u[0].length,!(i.ch<h)););if(!(!r.backtrack&&h<=i.ch)){if(u){var g=u[2]||u[4],y=u[3]||u[5],C=r.increase?1:-1,O={"0b":2,0:8,"":10,"0x":16}[g.toLowerCase()],x=parseInt(u[1]+y,O)+C*r.repeat;p=x.toString(O);var k=g?new Array(y.length-p.length+1+u[1].length).join("0"):"";p.charAt(0)==="-"?p="-"+g+k+p.substr(1):p=g+k+p;var w=new n(i.line,d),L=new n(i.line,h);e.replaceRange(p,w,L)}else return;e.setCursor(new n(i.line,d+p.length-1))}},repeatLastEdit:function(e,r,i){var a=i.lastEditInputState;if(a){var l=r.repeat;l&&r.repeatIsExplicit?a.repeatOverride=l:l=a.repeatOverride||l,or(e,i,l,!1)}},indent:function(e,r){e.indentLine(e.getCursor().line,r.indentRight)},exitInsertMode:function(e,r){Ze(e)}};function Pi(e,r){tt[e]=r}function Oe(e,r,i){var a=e.state.vim,l=a.insertMode||a.visualMode,u=Math.min(Math.max(e.firstLine(),r.line),e.lastLine()),d=e.getLine(u),h=d.length-1+ +!!l,p=Math.min(Math.max(0,r.ch),h),g=d.charCodeAt(p);if(56320<=g&&g<=57343){var y=1;i&&i.line==u&&i.ch>p&&(y=-1),p+=y,p>h&&(p-=2)}return new n(u,p)}function Rt(e){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r}function se(e,r,i){return typeof r=="object"&&(i=r.ch,r=r.line),new n(e.line+r,e.ch+i)}function Ni(e,r,i,a){a.operator&&(i="operatorPending");for(var l,u=[],d=[],h=Re?r.length-f:0,p=h;p<r.length;p++){var g=r[p];i=="insert"&&g.context!="insert"||g.context&&g.context!=i||a.operator&&g.type=="action"||!(l=Bi(e,g.keys))||(l=="partial"&&u.push(g),l=="full"&&d.push(g))}return{partial:u,full:d}}function Bi(e,r){const i=r.slice(-11)=="<character>",a=r.slice(-10)=="<register>";if(i||a){var l=r.length-(i?11:10),u=e.slice(0,l),d=r.slice(0,l);return u==d&&e.length>l?"full":d.indexOf(u)==0?"partial":!1}else return e==r?"full":r.indexOf(e)==0?"partial":!1}function Fi(e){var r=/^.*(<[^>]+>)$/.exec(e),i=r?r[1]:e.slice(-1);if(i.length>1)switch(i){case"<CR>":case"<S-CR>":i=`
|
|
19
|
-
`;break;case"<Space>":case"<S-Space>":i=" ";break;default:i="";break}return i}function Bn(e,r,i){return function(){for(var a=0;a<i;a++)r(e)}}function ee(e){return new n(e.line,e.ch)}function Ae(e,r){return e.ch==r.ch&&e.line==r.line}function ae(e,r){return e.line<r.line||e.line==r.line&&e.ch<r.ch}function xe(e,r){return arguments.length>2&&(r=xe.apply(void 0,Array.prototype.slice.call(arguments,1))),ae(e,r)?e:r}function Xe(e,r){return arguments.length>2&&(r=Xe.apply(void 0,Array.prototype.slice.call(arguments,1))),ae(e,r)?r:e}function Fn(e,r,i){var a=ae(e,r),l=ae(r,i);return a&&l}function Ce(e,r){return e.getLine(r).length}function Xt(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Ii(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function Di(e,r,i){var a=Ce(e,r),l=new Array(i-a+1).join(" ");e.setCursor(new n(r,a)),e.replaceRange(l,e.getCursor())}function In(e,r){var i=[],a=e.listSelections(),l=ee(e.clipPos(r)),u=!Ae(r,l),d=e.getCursor("head"),h=$i(a,d),p=Ae(a[h].head,a[h].anchor),g=a.length-1,y=g-h>h?g:0,C=a[y].anchor,O=Math.min(C.line,l.line),x=Math.max(C.line,l.line),k=C.ch,w=l.ch,L=a[y].head.ch-k,F=w-k;L>0&&F<=0?(k++,u||w--):L<0&&F>=0?(k--,p||w++):L<0&&F==-1&&(k--,w++);for(var N=O;N<=x;N++){var B={anchor:new n(N,k),head:new n(N,w)};i.push(B)}return e.setSelections(i),r.ch=w,C.ch=k,C}function Dn(e,r,i){for(var a=[],l=0;l<i;l++){var u=se(r,l,0);a.push({anchor:u,head:u})}e.setSelections(a,0)}function $i(e,r,i){for(var a=0;a<e.length;a++){var l=Ae(e[a].anchor,r),u=Ae(e[a].head,r);if(l||u)return a}return-1}function _i(e,r){var i=e.listSelections(),a=i[0],l=i[i.length-1],u=ae(a.anchor,a.head)?a.anchor:a.head,d=ae(l.anchor,l.head)?l.head:l.anchor;return[u,d]}function $n(e,r){var i=r.sel.anchor,a=r.sel.head;r.lastPastedText&&(a=e.posFromIndex(e.indexFromPos(i)+r.lastPastedText.length),r.lastPastedText=void 0),r.lastSelection={anchorMark:e.setBookmark(i),headMark:e.setBookmark(a),anchor:ee(i),head:ee(a),visualMode:r.visualMode,visualLine:r.visualLine,visualBlock:r.visualBlock}}function Qi(e,r,i,a){var l=e.state.vim.sel,u=a?r:l.head,d=a?r:l.anchor,h;return ae(i,r)&&(h=i,i=r,r=h),ae(u,d)?(u=xe(r,u),d=Xe(d,i)):(d=xe(r,d),u=Xe(u,i),u=se(u,0,-1),u.ch==-1&&u.line!=e.firstLine()&&(u=new n(u.line-1,Ce(e,u.line-1)))),[d,u]}function st(e,r,i){var a=e.state.vim;r=r||a.sel,i||(i=a.visualLine?"line":a.visualBlock?"block":"char");var l=Zt(e,r,i);e.setSelections(l.ranges,l.primary)}function Zt(e,r,i,a){var l=ee(r.head),u=ee(r.anchor);if(i=="char"){var d=!a&&!ae(r.head,r.anchor)?1:0,h=ae(r.head,r.anchor)?1:0;return l=se(r.head,0,d),u=se(r.anchor,0,h),{ranges:[{anchor:u,head:l}],primary:0}}else if(i=="line"){if(ae(r.head,r.anchor))l.ch=0,u.ch=Ce(e,u.line);else{u.ch=0;var p=e.lastLine();l.line>p&&(l.line=p),l.ch=Ce(e,l.line)}return{ranges:[{anchor:u,head:l}],primary:0}}else if(i=="block"){var g=Math.min(u.line,l.line),y=u.ch,C=Math.max(u.line,l.line),O=l.ch;y<O?O+=1:y+=1;for(var x=C-g+1,k=l.line==g?0:x-1,w=[],L=0;L<x;L++)w.push({anchor:new n(g+L,y),head:new n(g+L,O)});return{ranges:w,primary:k}}throw"never happens"}function Ki(e){var r=e.getCursor("head");return e.getSelection().length==1&&(r=xe(r,e.getCursor("anchor"))),r}function _e(e,r){var i=e.state.vim;r!==!1&&e.setCursor(Oe(e,i.sel.head)),$n(e,i),i.visualMode=!1,i.visualLine=!1,i.visualBlock=!1,i.insertMode||t.signal(e,"vim-mode-change",{mode:"normal"})}function Vi(e,r,i){var a=e.getRange(r,i);if(/\n\s*$/.test(a)){var l=a.split(`
|
|
20
|
-
`);l.pop();for(var u=l.pop();l.length>0&&u&&ce(u);u=l.pop())i.line--,i.ch=0;u?(i.line--,i.ch=Ce(e,i.line)):i.ch=0}}function ji(e,r,i){r.ch=0,i.ch=0,i.line++}function Qe(e){if(!e)return 0;var r=e.search(/\S/);return r==-1?e.length:r}function Yt(e,{inclusive:r,innerWord:i,bigWord:a,noSymbol:l,multiline:u},d){var h=d||Ki(e),p=e.getLine(h.line),g=p,y=h.line,C=y,O=h.ch,x,k=l?A[0]:E[0];if(i&&/\s/.test(p.charAt(O)))k=function(_){return/\s/.test(_)};else{for(;!k(p.charAt(O));)if(O++,O>=p.length){if(!u)return null;O--,x=Vn(e,h,!0,a,!0);break}a?k=E[0]:(k=A[0],k(p.charAt(O))||(k=A[1]))}for(var w=O,L=O;k(p.charAt(L))&&L>=0;)L--;if(L++,x)w=x.to,C=x.line,g=e.getLine(C),!g&&w==0&&w++;else for(;k(p.charAt(w))&&w<p.length;)w++;if(r){var F=w,N=h.ch<=L&&/\s/.test(p.charAt(h.ch));if(!N)for(;/\s/.test(g.charAt(w))&&w<g.length;)w++;if(F==w||N){for(var B=L;/\s/.test(p.charAt(L-1))&&L>0;)L--;!L&&!N&&(L=B)}}return{start:new n(y,L),end:new n(C,w)}}function qi(e,r,i){var a=r;if(!t.findMatchingTag||!t.findEnclosingTag)return{start:a,end:a};var l=t.findMatchingTag(e,r)||t.findEnclosingTag(e,r);return!l||!l.open||!l.close?{start:a,end:a}:i?{start:l.open.from,end:l.close.to}:{start:l.open.to,end:l.close.from}}function _n(e,r,i){Ae(r,i)||P.jumpList.add(e,r,i)}function Qn(e,r){P.lastCharacterSearch.increment=e,P.lastCharacterSearch.forward=r.forward,P.lastCharacterSearch.selectedCharacter=r.selectedCharacter}var zi={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},Kn={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 r=e.lastCh==="*"&&e.nextCh==="/";return e.lastCh=e.nextCh,r}},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 r=e.lineText.match(/^#(\w+)/)?.[1];if(r==="endif"){if(e.forward&&e.depth===0)return!0;e.depth++}else if(r==="if"){if(!e.forward&&e.depth===0)return!0;e.depth--}if(r==="else"&&e.depth===0)return!0}return!1}}};function Hi(e,r,i,a){var l=ee(e.getCursor()),u=i?1:-1,d=i?e.lineCount():-1,h=l.ch,p=l.line,g=e.getLine(p),y={lineText:g,nextCh:g.charAt(h),lastCh:null,index:h,symb:a,reverseSymb:(i?{")":"(","}":"{"}:{"(":")","{":"}"})[a],forward:i,depth:0,curMoveThrough:!1},C=zi[a];if(!C)return l;var O=Kn[C].init,x=Kn[C].isComplete;for(O&&O(y);p!==d&&r;){if(y.index+=u,y.nextCh=y.lineText.charAt(y.index),!y.nextCh){if(p+=u,y.lineText=e.getLine(p)||"",u>0)y.index=0;else{var k=y.lineText.length;y.index=k>0?k-1:0}y.nextCh=y.lineText.charAt(y.index)}x(y)&&(l.line=p,l.ch=y.index,r--)}return y.nextCh||y.curMoveThrough?new n(p,y.index):l}function Vn(e,r,i,a,l){var u=r.line,d=r.ch,h=e.getLine(u),p=i?1:-1,g=a?E:A;if(l&&h==""){if(u+=p,h=e.getLine(u),!ie(e,u))return null;d=i?0:h.length}for(;;){if(l&&h=="")return{from:0,to:0,line:u};for(var y=p>0?h.length:-1,C=y,O=y;d!=y;){for(var x=!1,k=0;k<g.length&&!x;++k)if(g[k](h.charAt(d))){for(C=d;d!=y&&g[k](h.charAt(d));)d+=p;if(O=d,x=C!=O,C==r.ch&&u==r.line&&O==C+p)continue;return{from:Math.min(C,O+1),to:Math.max(C,O),line:u}}x||(d+=p)}if(u+=p,!ie(e,u))return null;h=e.getLine(u),d=p>0?0:h.length}}function Wi(e,r,i,a,l,u){var d=ee(r),h=[];(a&&!l||!a&&l)&&i++;for(var p=!(a&&l),g=0;g<i;g++){var y=Vn(e,r,a,u,p);if(!y){var C=Ce(e,e.lastLine());h.push(a?{line:e.lastLine(),from:C,to:C}:{line:0,from:0,to:0});break}h.push(y),r=new n(y.line,a?y.to-1:y.from)}var O=h.length!=i,x=h[0],k=h.pop();return a&&!l?(!O&&(x.from!=d.ch||x.line!=d.line)&&(k=h.pop()),k&&new n(k.line,k.from)):a&&l?k&&new n(k.line,k.to-1):!a&&l?(!O&&(x.to!=d.ch||x.line!=d.line)&&(k=h.pop()),k&&new n(k.line,k.to)):k&&new n(k.line,k.from)}function jn(e,r,i,a,l){var u=r,d=new n(u.line+i.repeat-1,1/0),h=e.clipPos(d);return h.ch--,l||(a.lastHPos=1/0,a.lastHSPos=e.charCoords(h,"div").left),d}function Jt(e,r,i,a,l){if(a){for(var u=l||e.getCursor(),d=u.ch,h,p=0;p<r;p++){var g=e.getLine(u.line);if(h=Xi(d,g,a,i),h==-1)return;d=h}if(h!=null)return new n(e.getCursor().line,h)}}function Ui(e,r){var i=e.getCursor().line;return Oe(e,new n(i,r-1))}function We(e,r,i,a){!ot(i,T)&&!z.test(i)||(r.marks[i]&&r.marks[i].clear(),r.marks[i]=e.setBookmark(a))}function Xi(e,r,i,a,l){var u;return a?u=r.indexOf(i,e+1):u=r.lastIndexOf(i,e-1),u}function qn(e,r,i,a,l){var u=r.line,d=e.firstLine(),h=e.lastLine(),p,g,y=u;function C(L){return!e.getLine(L)}function O(L,F,N){return N?C(L)!=C(L+F):!C(L)&&C(L+F)}if(a){for(;d<=y&&y<=h&&i>0;)O(y,a)&&i--,y+=a;return{start:new n(y,0),end:r}}var x=e.state.vim;if(x.visualLine&&O(u,1,!0)){var k=x.sel.anchor;O(k.line,-1,!0)&&(!l||k.line!=u)&&(u+=1)}var w=C(u);for(y=u;y<=h&&i;y++)O(y,1,!0)&&(!l||C(y)!=w)&&i--;for(g=new n(y,0),y>h&&!w?w=!0:l=!1,y=u;y>d&&!((!l||C(y)==w||y==u)&&O(y,-1,!0));y--);return p=new n(y,0),{start:p,end:g}}function zn(e,r,i,a,l){function u(g){g.line!==null&&(g.pos+g.dir<0||g.pos+g.dir>=g.line.length?g.line=null:g.pos+=g.dir)}function d(g,y,C,O){var x=g.getLine(y),k={line:x,ln:y,pos:C,dir:O};if(k.line==="")return{ln:k.ln,pos:k.pos};var w=k.pos;for(u(k);k.line!==null;){if(w=k.pos,Ie(k.line[k.pos]))if(l){for(u(k);k.line!==null&&ce(k.line[k.pos]);)w=k.pos,u(k);return{ln:k.ln,pos:w+1}}else return{ln:k.ln,pos:k.pos+1};u(k)}return{ln:k.ln,pos:w+1}}function h(g,y,C,O){var x=g.getLine(y),k={line:x,ln:y,pos:C,dir:O};if(k.line==="")return{ln:k.ln,pos:k.pos};var w=k.pos;for(u(k);k.line!==null;){if(!ce(k.line[k.pos])&&!Ie(k.line[k.pos]))w=k.pos;else if(Ie(k.line[k.pos]))return l?ce(k.line[k.pos+1])?{ln:k.ln,pos:k.pos+1}:{ln:k.ln,pos:w}:{ln:k.ln,pos:w};u(k)}return k.line=x,l&&ce(k.line[k.pos])?{ln:k.ln,pos:k.pos}:{ln:k.ln,pos:w}}for(var p={ln:r.line,pos:r.ch};i>0;)a<0?p=h(e,p.ln,p.pos,a):p=d(e,p.ln,p.pos,a),i--;return new n(p.ln,p.pos)}function Zi(e,r,i,a){function l(p,g){if(g.line!==null)if(g.pos+g.dir<0||g.pos+g.dir>=g.line.length){if(g.ln+=g.dir,!ie(p,g.ln)){g.line=null;return}g.line=p.getLine(g.ln),g.pos=g.dir>0?0:g.line.length-1}else g.pos+=g.dir}function u(p,g,y,C){var L=p.getLine(g),O=L==="",x={line:L,ln:g,pos:y,dir:C},k={ln:x.ln,pos:x.pos},w=x.line==="";for(l(p,x);x.line!==null;){if(k.ln=x.ln,k.pos=x.pos,x.line===""&&!w)return{ln:x.ln,pos:x.pos};if(O&&x.line!==""&&!ce(x.line[x.pos]))return{ln:x.ln,pos:x.pos};Ie(x.line[x.pos])&&!O&&(x.pos===x.line.length-1||ce(x.line[x.pos+1]))&&(O=!0),l(p,x)}var L=p.getLine(k.ln);k.pos=0;for(var F=L.length-1;F>=0;--F)if(!ce(L[F])){k.pos=F;break}return k}function d(p,g,y,C){var L=p.getLine(g),O={line:L,ln:g,pos:y,dir:C},x=O.ln,k=null,w=O.line==="";for(l(p,O);O.line!==null;){if(O.line===""&&!w)return k!==null?{ln:x,pos:k}:{ln:O.ln,pos:O.pos};if(Ie(O.line[O.pos])&&k!==null&&!(O.ln===x&&O.pos+1===k))return{ln:x,pos:k};O.line!==""&&!ce(O.line[O.pos])&&(w=!1,x=O.ln,k=O.pos),l(p,O)}var L=p.getLine(x);k=0;for(var F=0;F<L.length;++F)if(!ce(L[F])){k=F;break}return{ln:x,pos:k}}for(var h={ln:r.line,pos:r.ch};i>0;)a<0?h=d(e,h.ln,h.pos,a):h=u(e,h.ln,h.pos,a),i--;return new n(h.ln,h.pos)}function Hn(e,r,i,a){var l=r,u={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[i],d={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[i],h=e.getLine(l.line).charAt(l.ch),p=h===d?1:0,g=e.scanForBracket(new n(l.line,l.ch+p),-1,void 0,{bracketRegex:u}),y=e.scanForBracket(new n(l.line,l.ch+p),1,void 0,{bracketRegex:u});if(!g||!y)return null;var C=g.pos,O=y.pos;if(C.line==O.line&&C.ch>O.ch||C.line>O.line){var x=C;C=O,O=x}return a?O.ch+=1:C.ch+=1,{start:C,end:O}}function Yi(e,r,i,a){var l=ee(r),u=e.getLine(l.line),d=u.split(""),h,p,g,y,C=d.indexOf(i);if(l.ch<C)l.ch=C;else if(C<l.ch&&d[l.ch]==i){var O=/string/.test(e.getTokenTypeAt(se(r,0,1))),x=/string/.test(e.getTokenTypeAt(r)),k=O&&!x;k||(p=l.ch,--l.ch)}if(d[l.ch]==i&&!p)h=l.ch+1;else for(g=l.ch;g>-1&&!h;g--)d[g]==i&&(h=g+1);if(h&&!p)for(g=h,y=d.length;g<y&&!p;g++)d[g]==i&&(p=g);return!h||!p?{start:l,end:l}:(a&&(--h,++p),{start:new n(l.line,h),end:new n(l.line,p)})}qe("pcre",!0,"boolean");class Ji{constructor(){this.highlightTimeout}getQuery(){return P.query}setQuery(r){P.query=r}getOverlay(){return this.searchOverlay}setOverlay(r){this.searchOverlay=r}isReversed(){return P.isReversed}setReversed(r){P.isReversed=r}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(r){this.annotate=r}}function Ne(e){var r=e.state.vim;return r.searchState_||(r.searchState_=new Ji)}function Gi(e){return Wn(e,"/")}function eo(e){return Un(e,"/")}function Wn(e,r){var i=Un(e,r)||[];if(!i.length)return[];var a=[];if(i[0]===0){for(var l=0;l<i.length;l++)typeof i[l]=="number"&&a.push(e.substring(i[l]+1,i[l+1]));return a}}function Un(e,r){r||(r="/");for(var i=!1,a=[],l=0;l<e.length;l++){var u=e.charAt(l);!i&&u==r&&a.push(l),i=!i&&u=="\\"}return a}function to(e){var r={V:"|(){+?*.[$^",M:"|(){+?*.[",m:"|(){+?",v:"<>"},i={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},a=r.m,l=e.replace(/\\.|[\[|(){+*?.$^<>]/g,function(d){if(d[0]==="\\"){var h=d[1];return h==="}"||a.indexOf(h)!=-1?h:h in r?(a=r[h],""):h in i?i[h]:d}else return a.indexOf(d)!=-1?i[d]||"\\"+d:d}),u=l.indexOf("\\zs");return u!=-1&&(l="(?<="+l.slice(0,u)+")"+l.slice(u+3)),u=l.indexOf("\\ze"),u!=-1&&(l=l.slice(0,u)+"(?="+l.slice(u+3)+")"),l}var Xn={"\\n":`
|
|
21
|
-
`,"\\r":"\r","\\t":" "};function no(e){for(var r=!1,i=[],a=-1;a<e.length;a++){var l=e.charAt(a)||"",u=e.charAt(a+1)||"";Xn[l+u]?(i.push(Xn[l+u]),a++):r?(i.push(l),r=!1):l==="\\"?(r=!0,he(u)||u==="$"?i.push("$"):u!=="/"&&u!=="\\"&&i.push("\\")):(l==="$"&&i.push("$"),i.push(l),u==="/"&&i.push("\\"))}return i.join("")}var Zn={"\\/":"/","\\\\":"\\","\\n":`
|
|
22
|
-
`,"\\r":"\r","\\t":" ","\\&":"&"};function ro(e){for(var r=new t.StringStream(e),i=[];!r.eol();){for(;r.peek()&&r.peek()!="\\";)i.push(r.next());var a=!1;for(var l in Zn)if(r.match(l,!0)){a=!0,i.push(Zn[l]);break}a||i.push(r.next())}return i.join("")}function Yn(e,r,i){var a=P.registerController.getRegister("/");a.setText(e);var l=eo(e),u,d;if(!l.length)u=e;else{u=e.substring(0,l[0]);var h=e.substring(l[0]);d=h.indexOf("i")!=-1}if(!u)return null;be("pcre")||(u=to(u)),i&&(r=/^[^A-Z]*$/.test(u));var p=new RegExp(u,r||d?"im":"m");return p}function Be(e){typeof e=="string"&&(e=document.createElement(e));for(var r=1;r<arguments.length;r++){var i=arguments[r];if(i)if(typeof i!="object"&&(i=document.createTextNode(i)),i.nodeType)e.appendChild(i);else for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(a[0]==="$"?e.style[a.slice(1)]=i[a]:typeof i[a]=="function"?e[a]=i[a]:e.setAttribute(a,i[a]))}return e}function H(e,r,i,a){var l=Be("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},r);e.openNotification?i?(l=Be("div",{},l,Be("div",{},"Press ENTER or type command to continue")),e.state.closeVimNotification&&e.state.closeVimNotification(),e.state.closeVimNotification=e.openNotification(l,{bottom:!0,duration:0})):e.openNotification(l,{bottom:!0,duration:a||15e3}):a||alert(l.innerText)}function io(e,r){return Be("div",{$display:"flex",$flex:1},Be("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},e,Be("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),r&&Be("span",{$color:"#888"},r))}function At(e,r){if(ke.length){r.value||(r.value=""),ne=r;return}var i=io(r.prefix,r.desc);if(e.openDialog)e.openDialog(i,r.onClose,{onKeyDown:r.onKeyDown,onKeyUp:r.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:r.value});else{var a="";typeof r.prefix!="string"&&r.prefix&&(a+=r.prefix.textContent),r.desc&&(a+=" "+r.desc),r.onClose?.(prompt(a,""))}}function oo(e,r){return e instanceof RegExp&&r instanceof RegExp?e.flags==r.flags&&e.source==r.source:!1}function mt(e,r,i,a){if(r){var l=Ne(e),u=Yn(r,!!i,!!a);if(u)return Gt(e,u),oo(u,l.getQuery())||l.setQuery(u),u}}function ao(e){if(e.source.charAt(0)=="^")var r=!0;return{token:function(i){if(r&&!i.sol()){i.skipToEnd();return}var a=i.match(e,!1);if(a)return a[0].length==0?(i.next(),"searching"):!i.sol()&&(i.backUp(1),!e.exec(i.next()+a[0]))?(i.next(),null):(i.match(e),"searching");for(;!i.eol()&&(i.next(),!i.match(e,!1)););},query:e}}var gt=0;function Gt(e,r){clearTimeout(gt);var i=Ne(e);i.highlightTimeout=gt,gt=setTimeout(function(){if(e.state.vim){var a=Ne(e);a.highlightTimeout=void 0;var l=a.getOverlay();(!l||r!=l.query)&&(l&&e.removeOverlay(l),l=ao(r),e.addOverlay(l),e.showMatchesOnScrollbar&&(a.getScrollbarAnnotate()&&a.getScrollbarAnnotate().clear(),a.setScrollbarAnnotate(e.showMatchesOnScrollbar(r))),a.setOverlay(l))}},50)}function Jn(e,r,i,a){return e.operation(function(){a===void 0&&(a=1);for(var l=e.getCursor(),u=e.getSearchCursor(i,l),d=0;d<a;d++){var h=u.find(r);if(d==0&&h&&Ae(u.from(),l)){var p=r?u.from():u.to();h=u.find(r),h&&!h[0]&&Ae(u.from(),p)&&e.getLine(p.line).length==p.ch&&(h=u.find(r))}if(!h&&(u=e.getSearchCursor(i,r?new n(e.lastLine()):new n(e.firstLine(),0)),!u.find(r)))return}return u.from()})}function so(e,r,i,a,l){return e.operation(function(){a===void 0&&(a=1);var u=e.getCursor(),d=e.getSearchCursor(i,u),h=d.find(!r);!l.visualMode&&h&&Ae(d.from(),u)&&d.find(!r);for(var p=0;p<a;p++)if(h=d.find(r),!h&&(d=e.getSearchCursor(i,r?new n(e.lastLine()):new n(e.firstLine(),0)),!d.find(r)))return;var g=d.from(),y=d.to();return g&&y&&[g,y]})}function lt(e){var r=Ne(e);r.highlightTimeout&&(clearTimeout(r.highlightTimeout),r.highlightTimeout=void 0),e.removeOverlay(Ne(e).getOverlay()),r.setOverlay(null),r.getScrollbarAnnotate()&&(r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(null))}function lo(e,r,i){return typeof e!="number"&&(e=e.line),r instanceof Array?ot(e,r):typeof i=="number"?e>=r&&e<=i:e==r}function en(e){var r=e.getScrollInfo(),i=6,a=10,l=e.coordsChar({left:0,top:i+r.top},"local"),u=r.clientHeight-a+r.top,d=e.coordsChar({left:0,top:u},"local");return{top:l.line,bottom:d.line}}function Pt(e,r,i){if(i=="'"||i=="`")return P.jumpList.find(e,-1)||new n(0,0);if(i==".")return Gn(e);var a=r.marks[i];return a&&a.find()}function Gn(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var r=e.doc.history.done,i=r.length;i--;)if(r[i].changes)return ee(r[i].changes[0].to)}class co{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(r,i,a){var l=this;r.operation(function(){r.curOp&&(r.curOp.isVimOp=!0),l._processCommand(r,i,a)})}_processCommand(r,i,a){var l=r.state.vim,u=P.registerController.getRegister(":"),d=u.toString(),h=new t.StringStream(i);u.setText(i);var p=a||{};p.input=i;try{this.parseInput_(r,h,p)}catch(C){H(r,C+"");return}l.visualMode&&_e(r);var g,y;if(!p.commandName)p.line!==void 0&&(y="move");else if(g=this.matchCommand_(p.commandName),g){if(y=g.name,g.excludeFromCommandHistory&&u.setText(d),this.parseCommandArgs_(h,p,g),g.type=="exToKey"){X(r,g.toKeys||"",g);return}else if(g.type=="exToEx"){this.processCommand(r,g.toInput||"");return}}if(!y){H(r,'Not an editor command ":'+i+'"');return}try{er[y](r,p),(!g||!g.possiblyAsync)&&p.callback&&p.callback()}catch(C){throw H(r,C+""),C}}parseInput_(r,i,a){if(i.eatWhile(":"),i.eat("%"))a.line=r.firstLine(),a.lineEnd=r.lastLine();else if(i.eat("*")){var l=r.state.vim.lastSelection,u=l?.anchorMark.find()?.line||0,d=l?.headMark.find()?.line||0;a.line=Math.max(u,d),a.lineEnd=Math.min(u,d)}else a.line=this.parseLineSpec_(r,i),a.line!==void 0&&i.eat(",")&&(a.lineEnd=this.parseLineSpec_(r,i));a.line==null?r.state.vim.visualMode?(a.selectionLine=Pt(r,r.state.vim,"<")?.line,a.selectionLineEnd=Pt(r,r.state.vim,">")?.line):a.selectionLine=r.getCursor().line:(a.selectionLine=a.line,a.selectionLineEnd=a.lineEnd),i.eatSpace();var h=i.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return h?a.commandName=h[1]:a.commandName=(i.match(/.*/)||[""])[0],a}parseLineSpec_(r,i){var a=i.match(/^([\d]+)/);if(a)return this.parseLineSpecOffset_(r,i,parseInt(a[1],10)-1);switch(i.next()){case".":return this.parseLineSpecOffset_(r,i,r.getCursor().line);case"$":return this.parseLineSpecOffset_(r,i,r.lastLine());case"'":var l=i.next()||"",u=Pt(r,r.state.vim,l);if(!u)throw new Error("Mark not set");return this.parseLineSpecOffset_(r,i,u.line);case"-":case"+":case"/":case"?":return i.backUp(1),this.parseLineSpecOffset_(r,i,r.getCursor().line);default:i.backUp(1);return}}parseLineSpecOffset_(r,i,a){for(;;){var l=i.match(/^([\/\?]|\\[\?\/])|([+-]?)(\d*)/);if(!l||!l[0])break;if(l[1]){var u="",d=!l[1].endsWith("?");if(l[1].length==1){var h=i.match(d?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);i.match(d?/^\/?/:/^\??/),u=h&&h[0]}u||(u=P.registerController.getRegister("/")?.toString()||"");var p=new RegExp(u),g=r.getSearchCursor(p,new n(a+(d?1:0),0));d?g.findNext():g.findPrevious();var y=g.from();if(!y)throw new Error("Pattern not found"+p);a=y.line}else{var C=parseInt(l[2]+(l[3]||"1"),10);a+=C}}return a}parseCommandArgs_(r,i,a){if(!r.eol()){i.argString=r.match(/.*/)?.[0];var l=a.argDelimiter||/\s+/,u=Xt(i.argString||"").split(l);u.length&&u[0]&&(i.args=u)}}matchCommand_(r){for(var i=r.length;i>0;i--){var a=r.substring(0,i);if(this.commandMap_[a]){var l=this.commandMap_[a];if(l.name.indexOf(r)===0)return l}}}buildCommandMap_(){this.commandMap_={};for(var r=0;r<m.length;r++){var i=m[r],a=i.shortName||i.name;this.commandMap_[a]=i}}map(r,i,a,l){if(r!=":"&&r.charAt(0)==":"){if(a)throw Error("Mode not supported for ex mappings");var u=r.substring(1);i!=":"&&i.charAt(0)==":"?this.commandMap_[u]={name:u,type:"exToEx",toInput:i.substring(1),user:!0}:this.commandMap_[u]={name:u,type:"exToKey",toKeys:i,user:!0}}else{var d={keys:r,type:"keyToKey",toKeys:i,noremap:!!l};a&&(d.context=a),tn(d)}}unmap(r,i){if(r!=":"&&r.charAt(0)==":"){if(i)throw Error("Mode not supported for ex mappings");var a=r.substring(1);if(this.commandMap_[a]&&this.commandMap_[a].user)return delete this.commandMap_[a],!0}else for(var l=r,u=0;u<s.length;u++)if(l==s[u].keys&&s[u].context===i)return s.splice(u,1),ho(l),!0}}var er={colorscheme:function(e,r){if(!r.args||r.args.length<1){H(e,e.getOption("theme"));return}e.setOption("theme",r.args[0])},map:function(e,r,i,a){var l=r.args;if(!l||l.length<2){e&&H(e,"Invalid mapping: "+r.input);return}Se.map(l[0],l[1],i,a)},imap:function(e,r){this.map(e,r,"insert")},nmap:function(e,r){this.map(e,r,"normal")},vmap:function(e,r){this.map(e,r,"visual")},omap:function(e,r){this.map(e,r,"operatorPending")},noremap:function(e,r){this.map(e,r,void 0,!0)},inoremap:function(e,r){this.map(e,r,"insert",!0)},nnoremap:function(e,r){this.map(e,r,"normal",!0)},vnoremap:function(e,r){this.map(e,r,"visual",!0)},onoremap:function(e,r){this.map(e,r,"operatorPending",!0)},unmap:function(e,r,i){var a=r.args;(!a||a.length<1||!Se.unmap(a[0],i))&&e&&H(e,"No such mapping: "+r.input)},mapclear:function(e,r){pe.mapclear()},imapclear:function(e,r){pe.mapclear("insert")},nmapclear:function(e,r){pe.mapclear("normal")},vmapclear:function(e,r){pe.mapclear("visual")},omapclear:function(e,r){pe.mapclear("operatorPending")},move:function(e,r){et.processCommand(e,e.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:r.line+1})},set:function(e,r){var i=r.args,a=r.setCfg||{};if(!i||i.length<1){e&&H(e,"Invalid mapping: "+r.input);return}var l=i[0].split("="),u=l.shift()||"",d=l.length>0?l.join("="):void 0,h=!1,p=!1;if(u.charAt(u.length-1)=="?"){if(d)throw Error("Trailing characters: "+r.argString);u=u.substring(0,u.length-1),h=!0}else u.charAt(u.length-1)=="!"&&(u=u.substring(0,u.length-1),p=!0);d===void 0&&u.substring(0,2)=="no"&&(u=u.substring(2),d=!1);var g=Te[u]&&Te[u].type=="boolean";if(g&&(p?d=!be(u,e,a):d==null&&(d=!0)),!g&&d===void 0||h){var y=be(u,e,a);y instanceof Error?H(e,y.message):y===!0||y===!1?H(e," "+(y?"":"no")+u):H(e," "+u+"="+y)}else{var C=Ye(u,d,e,a);C instanceof Error&&H(e,C.message)}},setlocal:function(e,r){r.setCfg={scope:"local"},this.set(e,r)},setglobal:function(e,r){r.setCfg={scope:"global"},this.set(e,r)},registers:function(e,r){var i=r.args,a=P.registerController.registers,l=`----------Registers----------
|
|
23
|
-
|
|
24
|
-
`;if(i)for(var h=i.join(""),p=0;p<h.length;p++){var u=h.charAt(p);if(P.registerController.isValidRegister(u)){var g=a[u]||new De;l+='"'+u+" "+g.toString()+`
|
|
25
|
-
`}}else for(var u in a){var d=a[u].toString();d.length&&(l+='"'+u+" "+d+`
|
|
26
|
-
`)}H(e,l,!0)},marks:function(e,r){var i=r.args,a=e.state.vim.marks,l=`-----------Marks-----------
|
|
27
|
-
mark line col
|
|
28
|
-
|
|
29
|
-
`;if(i)for(var h=i.join(""),p=0;p<h.length;p++){var u=h.charAt(p),d=a[u]&&a[u].find();d&&(l+=u+" "+d.line+" "+d.ch+`
|
|
30
|
-
`)}else for(var u in a){var d=a[u]&&a[u].find();d&&(l+=u+" "+d.line+" "+d.ch+`
|
|
31
|
-
`)}H(e,l,!0)},sort:function(e,r){var i,a,l,u,d,h;function p(){if(r.argString){var q=new t.StringStream(r.argString);if(q.eat("!")&&(i=!0),q.eol())return;if(!q.eatSpace())return"Invalid arguments";var K=q.match(/([dinuoxr]+)?\s*(\/.+\/)?\s*/);if(!K||!q.eol())return"Invalid arguments";if(K[1]){h=K[1].indexOf("r")!=-1,a=K[1].indexOf("i")!=-1,l=K[1].indexOf("u")!=-1;var we=K[1].indexOf("d")!=-1||K[1].indexOf("n")!=-1,ge=K[1].indexOf("x")!=-1,ve=K[1].indexOf("o")!=-1;if(Number(we)+Number(ge)+Number(ve)>1)return"Invalid arguments";u=we&&"decimal"||ge&&"hex"||ve&&"octal"}K[2]&&(d=new RegExp(K[2].substr(1,K[2].length-2),a?"i":""))}}var g=p();if(g){H(e,g+": "+r.argString);return}var y=r.line||e.firstLine(),C=r.lineEnd||r.line||e.lastLine();if(y==C)return;var O=new n(y,0),x=new n(C,Ce(e,C)),k=e.getRange(O,x).split(`
|
|
32
|
-
`),w=u=="decimal"?/(-?)([\d]+)/:u=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:u=="octal"?/([0-7]+)/:null,L=u=="decimal"?10:u=="hex"?16:u=="octal"?8:void 0,F=[],N=[];if(u||d)for(var B=0;B<k.length;B++){var _=d?k[B].match(d):null;_&&_.index!=null&&!h&&(_[0]=k[B].slice(_.index+_[0].length)),_&&_[0]!=""?F.push(_):w&&w.exec(k[B])?F.push(k[B]):N.push(k[B])}else N=k;function V(q,K){if(i){var we;we=q,q=K,K=we}a&&(q=q.toLowerCase(),K=K.toLowerCase());var ge=w&&w.exec(q),ve=w&&w.exec(K);if(!ge||!ve)return q<K?-1:1;var nt=parseInt((ge[1]+ge[2]).toLowerCase(),L),rn=parseInt((ve[1]+ve[2]).toLowerCase(),L);return nt-rn}function le(q,K){if(i){var we;we=q,q=K,K=we}return a&&(q[0]=q[0].toLowerCase(),K[0]=K[0].toLowerCase()),q[0]<K[0]?-1:1}if(F.sort(d?le:V),d)for(var B=0;B<F.length;B++)F[B]=F[B].input;else u||N.sort(V);if(k=i?F.concat(N):N.concat(F),l){var te=k,me;k=[];for(var B=0;B<te.length;B++)te[B]!=me&&k.push(te[B]),me=te[B]}e.replaceRange(k.join(`
|
|
33
|
-
`),O,x)},vglobal:function(e,r){this.global(e,r)},normal:function(e,r){var i=!1,a=r.argString;if(a&&a[0]=="!"&&(a=a.slice(1),i=!0),a=a.trimStart(),!a){H(e,"Argument is required.");return}var l=r.line;if(typeof l=="number")for(var u=isNaN(r.lineEnd)?l:r.lineEnd,d=l;d<=u;d++)e.setCursor(d,0),X(e,r.argString.trimStart(),{noremap:i}),e.state.vim.insertMode&&Ze(e,!0);else X(e,r.argString.trimStart(),{noremap:i}),e.state.vim.insertMode&&Ze(e,!0)},global:function(e,r){var i=r.argString;if(!i){H(e,"Regular Expression missing from global");return}var a=r.commandName[0]==="v";i[0]==="!"&&r.commandName[0]==="g"&&(a=!0,i=i.slice(1));var l=r.line!==void 0?r.line:e.firstLine(),u=r.lineEnd||r.line||e.lastLine(),d=Gi(i),h=i,p="";if(d&&d.length&&(h=d[0],p=d.slice(1,d.length).join("/")),h)try{mt(e,h,!0,!0)}catch{H(e,"Invalid regex: "+h);return}for(var g=Ne(e).getQuery(),y=[],C=l;C<=u;C++){var O=e.getLine(C),x=g.test(O);x!==a&&y.push(p?e.getLineHandle(C):O)}if(!p){H(e,y.join(`
|
|
34
|
-
`));return}var k=0,w=function(){if(k<y.length){var L=y[k++],F=e.getLineNumber(L);if(F==null){w();return}var N=F+1+p;Se.processCommand(e,N,{callback:w})}else e.releaseLineHandles&&e.releaseLineHandles()};w()},substitute:function(e,r){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var i=r.argString,a=i?Wn(i,i[0]):[],l="",u="",d,h,p,g=!1,y=!1;if(a&&a.length)l=a[0],be("pcre")&&l!==""&&(l=new RegExp(l).source),u=a[1],u!==void 0&&(be("pcre")?u=ro(u.replace(/([^\\])&/g,"$1$$&")):u=no(u),P.lastSubstituteReplacePart=u),d=a[2]?a[2].split(" "):[];else if(i&&i.length){H(e,"Substitutions should be of the form :s/pattern/replace/");return}if(d&&(h=d[0],p=parseInt(d[1]),h&&(h.indexOf("c")!=-1&&(g=!0),h.indexOf("g")!=-1&&(y=!0),be("pcre")?l=l+"/"+h:l=l.replace(/\//g,"\\/")+"/"+h)),l)try{mt(e,l,!0,!0)}catch{H(e,"Invalid regex: "+l);return}if(u=u||P.lastSubstituteReplacePart,u===void 0){H(e,"No previous substitute regular expression");return}var C=Ne(e),O=C.getQuery(),x=r.line!==void 0?r.line:e.getCursor().line,k=r.lineEnd||x;x==e.firstLine()&&k==e.lastLine()&&(k=1/0),p&&(x=k,k=x+p-1);var w=Oe(e,new n(x,0)),L=e.getSearchCursor(O,w);uo(e,g,y,x,k,L,O,u,r.callback)},startinsert:function(e,r){X(e,r.argString=="!"?"A":"i",{})},redo:t.commands.redo,undo:t.commands.undo,write:function(e){t.commands.save?t.commands.save(e):e.save&&e.save()},nohlsearch:function(e){lt(e)},yank:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;if(a<i){var l=a;a=i,i=l}var u=e.getRange(new n(i,0),new n(a+1,0)),d=r.args&&r.args[0]?r.args[0]:"0";P.registerController.pushText(d,"yank",u,!0,!1),H(e,a+1-i+" lines yanked"+(d?' into "'+d:""),!1,1500)},put:function(e,r,i){var a={after:!0,isEdit:!0,matchIndent:!!i,repeat:1,lineWise:!0,registerName:""},l=r.args||[];l[0]=="!"&&(a.after=!1,l.shift()),l[0]&&(a.registerName=l[0]);var u=r.selectionLine;u!=null&&e.setCursor(new n(u,0)),tt.paste(e,a,e.state.vim)},iput:function(e,r){this.put(e,r,!0)},delete:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;Ut.delete(e,{linewise:!0},[{anchor:new n(i,0),head:new n(a+1,0)}])},join:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;e.setCursor(new n(i,0)),tt.joinLines(e,{repeat:a-i},e.state.vim)},delmarks:function(e,r){if(!r.argString||!Xt(r.argString)){H(e,"Argument required");return}for(var i=e.state.vim,a=new t.StringStream(Xt(r.argString));!a.eol();){a.eatSpace();var l=a.pos;if(!a.match(/[a-zA-Z]/,!1)){H(e,"Invalid argument: "+r.argString.substring(l));return}var u=a.next();if(a.match("-",!0)){if(!a.match(/[a-zA-Z]/,!1)){H(e,"Invalid argument: "+r.argString.substring(l));return}var d=u,h=a.next();if(d&&h&&Q(d)==Q(h)){var p=d.charCodeAt(0),g=h.charCodeAt(0);if(p>=g){H(e,"Invalid argument: "+r.argString.substring(l));return}for(var y=0;y<=g-p;y++){var C=String.fromCharCode(p+y);delete i.marks[C]}}else{H(e,"Invalid argument: "+d+"-");return}}else u&&delete i.marks[u]}}},Se=new co;pe.defineEx("version","ve",e=>{H(e,"Codemirror-vim version: <DEV>")});function uo(e,r,i,a,l,u,d,h,p){e.state.vim.exMode=!0;var g=!1,y=0,C,O,x;function k(){e.operation(function(){for(;!g;)w(),F();N()})}function w(){var _="",V=u.match||u.pos&&u.pos.match;if(V)_=h.replace(/\$(\d{1,3}|[$&])/g,function(me,q){if(q=="$")return"$";if(q=="&")return V[0];for(var K=q;parseInt(K)>=V.length&&K.length>0;)K=K.slice(0,K.length-1);return K?V[K]+q.slice(K.length,q.length):me});else{var le=e.getRange(u.from(),u.to());_=le.replace(d,h)}var te=u.to().line;u.replace(_),O=u.to().line,l+=O-te,x=O<te}function L(){var _=C&&ee(u.to()),V=u.findNext();return V&&!V[0]&&_&&Ae(u.from(),_)&&(V=u.findNext()),V&&y++,V}function F(){for(;L()&&lo(u.from(),a,l);)if(!(!i&&u.from().line==O&&!x)){e.scrollIntoView(u.from(),30),e.setSelection(u.from(),u.to()),C=u.from(),g=!1;return}g=!0}function N(_){if(_&&_(),e.focus(),C){e.setCursor(C);var V=e.state.vim;V.exMode=!1,V.lastHPos=V.lastHSPos=C.ch}p?p():g&&H(e,(y?"Found "+y+" matches":"No matches found")+" for pattern: "+d+(be("pcre")?" (set nopcre to use Vim regexps)":""))}function B(_,V,le){t.e_stop(_);var te=re(_);switch(te){case"y":w(),F();break;case"n":F();break;case"a":var me=p;p=void 0,e.operation(k),p=me;break;case"l":w();case"q":case"<Esc>":case"<C-c>":case"<C-[>":N(le);break}return g&&N(le),!0}if(F(),g){H(e,"No matches for "+d+(be("pcre")?" (set nopcre to use vim regexps)":""));return}if(!r){k(),p&&p();return}At(e,{prefix:Be("span","replace with ",Be("strong",h)," (y/n/a/q/l)"),onKeyDown:B})}function Ze(e,r){var i=e.state.vim,a=P.macroModeState,l=P.registerController.getRegister("."),u=a.isPlaying,d=a.lastInsertModeChanges;u||(e.off("change",tr),i.insertEnd&&i.insertEnd.clear(),i.insertEnd=void 0,t.off(e.getInputField(),"keydown",ir)),!u&&i.insertModeRepeat&&i.insertModeRepeat>1&&(or(e,i,i.insertModeRepeat-1,!0),i.lastEditInputState.repeatOverride=i.insertModeRepeat),delete i.insertModeRepeat,i.insertMode=!1,r||e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),l.setText(d.changes.join("")),t.signal(e,"vim-mode-change",{mode:"normal"}),a.isRecording&&vo(a)}function tn(e){s.unshift(e),e.keys&&fo(e.keys)}function fo(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(r){r&&(c[r]||(c[r]=0),c[r]++)})}function ho(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(r){c[r]&&c[r]--})}function po(e,r,i,a,l){var u={keys:e,type:r};u[r]=i,u[r+"Args"]=a;for(var d in l)u[d]=l[d];tn(u)}qe("insertModeEscKeysTimeout",200,"number");function mo(e,r,i,a){var l=P.registerController.getRegister(a);if(a==":"){l.keyBuffer[0]&&Se.processCommand(e,l.keyBuffer[0]),i.isPlaying=!1;return}var u=l.keyBuffer,d=0;i.isPlaying=!0,i.replaySearchQueries=l.searchQueries.slice(0);for(var h=0;h<u.length;h++)for(var p=u[h],g,y,C=/<(?:[CSMA]-)*\w+>|./gi;g=C.exec(p);)if(y=g[0],pe.handleKey(e,y,"macro"),r.insertMode){var O=l.insertModeChanges[d++].changes;P.macroModeState.lastInsertModeChanges.changes=O,sr(e,O,1),Ze(e)}i.isPlaying=!1}function go(e,r){if(!e.isPlaying){var i=e.latestRegister,a=P.registerController.getRegister(i);a&&a.pushText(r)}}function vo(e){if(!e.isPlaying){var r=e.latestRegister,i=P.registerController.getRegister(r);i&&i.pushInsertModeChanges&&i.pushInsertModeChanges(e.lastInsertModeChanges)}}function yo(e,r){if(!e.isPlaying){var i=e.latestRegister,a=P.registerController.getRegister(i);a&&a.pushSearchQuery&&a.pushSearchQuery(r)}}function tr(e,r){var i=P.macroModeState,a=i.lastInsertModeChanges;if(!i.isPlaying)for(var l=e.state.vim;r;){if(a.expectCursorActivityForChange=!0,a.ignoreCount>1)a.ignoreCount--;else if(r.origin=="+input"||r.origin=="paste"||r.origin===void 0){var u=e.listSelections().length;u>1&&(a.ignoreCount=u);var d=r.text.join(`
|
|
35
|
-
`);if(a.maybeReset&&(a.changes=[],a.maybeReset=!1),d)if(e.state.overwrite&&!/\n/.test(d))a.changes.push([d]);else{if(d.length>1){var h=l&&l.insertEnd&&l.insertEnd.find(),p=e.getCursor();if(h&&h.line==p.line){var g=h.ch-p.ch;g>0&&g<d.length&&(a.changes.push([d,g]),d="")}}d&&a.changes.push(d)}}r=r.next}}function nr(e){var r=e.state.vim;if(r.insertMode){var i=P.macroModeState;if(i.isPlaying)return;var a=i.lastInsertModeChanges;a.expectCursorActivityForChange?a.expectCursorActivityForChange=!1:(a.maybeReset=!0,r.insertEnd&&r.insertEnd.clear(),r.insertEnd=e.setBookmark(e.getCursor(),{insertLeft:!0}))}else e.curOp?.isVimOp||rr(e,r)}function rr(e,r){var i=e.getCursor("anchor"),a=e.getCursor("head");if(r.visualMode&&!e.somethingSelected()?_e(e,!1):!r.visualMode&&!r.insertMode&&e.somethingSelected()&&(r.visualMode=!0,r.visualLine=!1,t.signal(e,"vim-mode-change",{mode:"visual"})),r.visualMode){var l=ae(a,i)?0:-1,u=ae(a,i)?-1:0;a=se(a,0,l),i=se(i,0,u),r.sel={anchor:i,head:a},We(e,r,"<",xe(a,i)),We(e,r,">",Xe(a,i))}else r.insertMode||(r.lastHPos=e.getCursor().ch)}function ir(e){var r=P.macroModeState,i=r.lastInsertModeChanges,a=t.keyName?t.keyName(e):e.key;a&&(a.indexOf("Delete")!=-1||a.indexOf("Backspace")!=-1)&&(i.maybeReset&&(i.changes=[],i.maybeReset=!1),i.changes.push(new He(a,e)))}function or(e,r,i,a){var l=P.macroModeState;l.isPlaying=!0;var u=r.lastEditActionCommand,d=r.inputState;function h(){u?et.processAction(e,r,u):et.evalInput(e,r)}function p(y){if(l.lastInsertModeChanges.changes.length>0){y=r.lastEditActionCommand?y:1;var C=l.lastInsertModeChanges;sr(e,C.changes,y)}}if(r.inputState=r.lastEditInputState,u&&u.interlaceInsertRepeat)for(var g=0;g<i;g++)h(),p(1);else a||h(),p(i);r.inputState=d,r.insertMode&&!a&&Ze(e),l.isPlaying=!1}function ar(e,r){t.lookupKey(r,"vim-insert",function(a){return typeof a=="string"?t.commands[a](e):a(e),!0})}function sr(e,r,i){var a=e.getCursor("head"),l=P.macroModeState.lastInsertModeChanges.visualBlock;l&&(Dn(e,a,l+1),i=e.listSelections().length,e.setCursor(a));for(var u=0;u<i;u++){l&&e.setCursor(se(a,u,0));for(var d=0;d<r.length;d++){var h=r[d];if(h instanceof He)ar(e,h.keyName);else if(typeof h=="string")e.replaceSelection(h);else{var p=e.getCursor(),g=se(p,0,h[0].length-(h[1]||0));e.replaceRange(h[0],p,h[1]?p:g),e.setCursor(g)}}}l&&e.setCursor(se(a,0,1))}function nn(e){var r=new e.constructor;return Object.keys(e).forEach(function(i){if(i!="insertEnd"){var a=e[i];Array.isArray(a)?a=a.slice():a&&typeof a=="object"&&a.constructor!=Object&&(a=nn(a)),r[i]=a}}),e.sel&&(r.sel={head:e.sel.head&&ee(e.sel.head),anchor:e.sel.anchor&&ee(e.sel.anchor)}),r}function bo(e,r,i){var u=ze(e),a=e,l=!1,u=pe.maybeInitVimState_(a),d=u.visualBlock||u.wasInVisualBlock;if(a.state.closeVimNotification){var h=a.state.closeVimNotification;if(a.state.closeVimNotification=null,h(),r=="<CR>")return ue(a),!0}var p=a.isInMultiSelectMode();if(u.wasInVisualBlock&&!p?u.wasInVisualBlock=!1:p&&u.visualBlock&&(u.wasInVisualBlock=!0),r=="<Esc>"&&!u.insertMode&&!u.visualMode&&p&&u.status=="<Esc>")ue(a);else if(d||!p||a.inVirtualSelectionMode)l=pe.handleKey(a,r,i);else{var g=nn(u),y=u.inputState.changeQueueList||[];a.operation(function(){a.curOp&&(a.curOp.isVimOp=!0);var C=0;a.forEachSelection(function(){a.state.vim.inputState.changeQueue=y[C];var O=a.getCursor("head"),x=a.getCursor("anchor"),k=ae(O,x)?0:-1,w=ae(O,x)?-1:0;O=se(O,0,k),x=se(x,0,w),a.state.vim.sel.head=O,a.state.vim.sel.anchor=x,l=pe.handleKey(a,r,i),a.virtualSelection&&(y[C]=a.state.vim.inputState.changeQueue,a.state.vim=nn(g)),C++}),a.curOp?.cursorActivity&&!l&&(a.curOp.cursorActivity=!1),a.state.vim=u,u.inputState.changeQueueList=y,u.inputState.changeQueue=null},!0)}return l&&!u.visualMode&&!u.insertMode&&u.visualMode!=a.somethingSelected()&&rr(a,u),l}return pt(),pe}function Ee(t,n){var o=n.ch,s=n.line+1;s<1&&(s=1,o=0),s>t.lines&&(s=t.lines,o=Number.MAX_VALUE);var c=t.line(s);return Math.min(c.from+Math.max(0,o),c.to)}function Pe(t,n){let o=t.lineAt(n);return{line:o.number-1,ch:n-o.from}}class Ve{constructor(n,o){this.line=n,this.ch=o}}function Yr(t,n,o){if(t.addEventListener)t.addEventListener(n,o,!1);else{var s=t._handlers||(t._handlers={});s[n]=(s[n]||[]).concat(o)}}function Jr(t,n,o){if(t.removeEventListener)t.removeEventListener(n,o,!1);else{var s=t._handlers,c=s&&s[n];if(c){var f=c.indexOf(o);f>-1&&(s[n]=c.slice(0,f).concat(c.slice(f+1)))}}}function Gr(t,n,...o){var s,c=(s=t._handlers)===null||s===void 0?void 0:s[n];if(c)for(var f=0;f<c.length;++f)c[f](...o)}function hr(t,...n){if(t)for(var o=0;o<t.length;++o)t[o](...n)}let hn;try{hn=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{hn=/[\w]/}function vt(t,n){var o=t.cm6;if(!o.state.readOnly){var s="input.type.compose";if(t.curOp&&(t.curOp.lastChange||(s="input.type.compose.start")),n.annotations)try{n.annotations.some(function(c){c.value=="input"&&(c.value=s)})}catch(c){console.error(c)}else n.userEvent=s;return o.dispatch(n)}}function pr(t,n){var o;t.curOp&&(t.curOp.$changeStart=void 0),(n?Do:$o)(t.cm6);let s=(o=t.curOp)===null||o===void 0?void 0:o.$changeStart;s!=null&&t.cm6.dispatch({selection:{anchor:s}})}var Sa={Left:t=>ct(t.cm6,{key:"Left"},"editor"),Right:t=>ct(t.cm6,{key:"Right"},"editor"),Up:t=>ct(t.cm6,{key:"Up"},"editor"),Down:t=>ct(t.cm6,{key:"Down"},"editor"),Backspace:t=>ct(t.cm6,{key:"Backspace"},"editor"),Delete:t=>ct(t.cm6,{key:"Delete"},"editor")};class j{openDialog(n,o,s){return Ma(this,n,o,s)}openNotification(n,o){return wa(this,n,o)}constructor(n){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=n,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(n,o){Yr(this,n,o)}off(n,o){Jr(this,n,o)}signal(n,o,s){Gr(this,n,o,s)}indexFromPos(n){return Ee(this.cm6.state.doc,n)}posFromIndex(n){return Pe(this.cm6.state.doc,n)}foldCode(n){let o=this.cm6,s=o.state.selection.ranges,c=this.cm6.state.doc,f=Ee(c,n),m=Le.create([Le.range(f,f)],0).ranges;o.state.selection.ranges=m,Oo(o),o.state.selection.ranges=s}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(n,o){typeof n=="object"&&(o=n.ch,n=n.line);var s=Ee(this.cm6.state.doc,{line:n,ch:o||0});this.cm6.dispatch({selection:{anchor:s}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(n){var o=this.cm6.state.selection.main,s=n=="head"||!n?o.head:n=="anchor"?o.anchor:n=="start"?o.from:n=="end"?o.to:null;if(s==null)throw new Error("Invalid cursor type");return this.posFromIndex(s)}listSelections(){var n=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(o=>({anchor:Pe(n,o.anchor),head:Pe(n,o.head)}))}setSelections(n,o){var s=this.cm6.state.doc,c=n.map(f=>{var m=Ee(s,f.head),v=Ee(s,f.anchor);return m==v?Le.cursor(m,1):Le.range(v,m)});this.cm6.dispatch({selection:Le.create(c,o)})}setSelection(n,o,s){this.setSelections([{anchor:n,head:o}],0),s&&s.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(n){var o=this.cm6.state.doc;return n<0||n>=o.lines?"":this.cm6.state.doc.line(n+1).text}getLineHandle(n){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:n,index:this.indexFromPos(new Ve(n,0))}}getLineNumber(n){var o=this.$lineHandleChanges;if(!o)return null;for(var s=n.index,c=0;c<o.length;c++)if(s=o[c].changes.mapPos(s,1,qr.TrackAfter),s==null)return null;var f=this.posFromIndex(s);return f.ch==0?f.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(n,o){var s=this.cm6.state.doc;return this.cm6.state.sliceDoc(Ee(s,n),Ee(s,o))}replaceRange(n,o,s,c){s||(s=o);var f=this.cm6.state.doc,m=Ee(f,o),v=Ee(f,s);vt(this,{changes:{from:m,to:v,insert:n}})}replaceSelection(n){vt(this,this.cm6.state.replaceSelection(n))}replaceSelections(n){var o=this.cm6.state.selection.ranges,s=o.map((c,f)=>({from:c.from,to:c.to,insert:n[f]||""}));vt(this,{changes:s})}getSelection(){return this.getSelections().join(`
|
|
36
|
-
`)}getSelections(){var n=this.cm6;return n.state.selection.ranges.map(o=>n.state.sliceDoc(o.from,o.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(n=>!n.empty)}getInputField(){return this.cm6.contentDOM}clipPos(n){var o=this.cm6.state.doc,s=n.ch,c=n.line+1;c<1&&(c=1,s=0),c>o.lines&&(c=o.lines,s=Number.MAX_VALUE);var f=o.line(c);return s=Math.min(Math.max(0,s),f.to-f.from),new Ve(c-1,s)}getValue(){return this.cm6.state.doc.toString()}setValue(n){var o=this.cm6;return o.dispatch({changes:{from:0,to:o.state.doc.length,insert:n},selection:Le.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(n,o){var s=this.cm6.state,c=Ee(s.doc,n),f=lr(s,c+1,-1);return f&&f.end?{to:Pe(s.doc,f.end.from)}:(f=lr(s,c,1),f&&f.end?{to:Pe(s.doc,f.end.from)}:{to:void 0})}scanForBracket(n,o,s,c){return Ta(this,n,o,s,c)}indentLine(n,o){o?this.indentMore():this.indentLess()}indentMore(){xo(this.cm6)}indentLess(){So(this.cm6)}execCommand(n){if(j.commands.hasOwnProperty(n))j.commands[n](this);else if(n=="goLineLeft")wo(this.cm6);else if(n=="goLineRight"){Mo(this.cm6);let o=this.cm6.state,s=o.selection.main.head;s<o.doc.length&&o.sliceDoc(s,s+1)!==`
|
|
37
|
-
`&&Eo(this.cm6)}else console.log(n+" is not implemented")}setBookmark(n,o){var s=o?.insertLeft?1:-1,c=this.indexFromPos(n),f=new Pa(this,c,s);return f}addOverlay({query:n}){let o=new Lo({regexp:!0,search:n.source,caseSensitive:!/i/.test(n.flags)});if(o.valid){o.forVim=!0,this.cm6Query=o;let s=un.of(o);return this.cm6.dispatch({effects:s}),o}}removeOverlay(n){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let o=un.of(this.cm6Query);this.cm6.dispatch({effects:o})}getSearchCursor(n,o){var s=this,c=null,f=null,m=!1;o.ch==null&&(o.ch=Number.MAX_VALUE);var v=Ee(s.cm6.state.doc,o),b=n.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(E,T){return T||"\\"+E});function S(E,T=0,D=E.length){return new Ro(E,b,{ignoreCase:n.ignoreCase},T,D)}function M(E){var T=s.cm6.state.doc;if(E>T.length)return null;let D=S(T,E).next();return D.done?null:D.value}var R=1e4;function A(E,T){var D=s.cm6.state.doc;for(let z=1;;z++){let W=Math.max(E,T-z*R),ie=S(D,W,T),Q=null;for(;!ie.next().done;)Q=ie.value;if(Q&&(W==E||Q.from>W+10))return Q;if(W==E)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(E){var T=s.cm6.state.doc;if(E){let D=c?m?c.to-1:c.from:v;c=A(0,D)}else{let D=c?m?c.to+1:c.to:v;c=M(D)}return f=c&&{from:Pe(T,c.from),to:Pe(T,c.to),match:c.match},m=c?c.from==c.to:!1,c&&c.match},from:function(){return f?.from},to:function(){return f?.to},replace:function(E){c&&(vt(s,{changes:{from:c.from,to:c.to,insert:E}}),c.to=c.from+E.length,f&&(f.to=Pe(s.cm6.state.doc,c.to)))},get match(){return f&&f.match}}}findPosV(n,o,s,c){let{cm6:f}=this;const m=f.state.doc;let v=s=="page"?f.dom.clientHeight:0;const b=Ee(m,n);let S=Le.cursor(b,1,void 0,c),M=Math.round(Math.abs(o));for(let A=0;A<M;A++)s=="page"?S=f.moveVertically(S,o>0,v):s=="line"&&(S=f.moveVertically(S,o>0));let R=Pe(m,S.head);return(o<0&&S.head==0&&c!=0&&n.line==0&&n.ch!=0||o>0&&S.head==m.length&&R.ch!=c&&n.line==R.line)&&(R.hitSide=!0),R}charCoords(n,o){var s=this.cm6.contentDOM.getBoundingClientRect(),c=Ee(this.cm6.state.doc,n),f=this.cm6.coordsAtPos(c),m=-s.top;return{left:(f?.left||0)-s.left,top:(f?.top||0)+m,bottom:(f?.bottom||0)+m}}coordsChar(n,o){var s=this.cm6.contentDOM.getBoundingClientRect(),c=this.cm6.posAtCoords({x:n.left+s.left,y:n.top+s.top})||0;return Pe(this.cm6.state.doc,c)}getScrollInfo(){var n=this.cm6.scrollDOM;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight,width:n.scrollWidth,clientHeight:n.clientHeight,clientWidth:n.clientWidth}}scrollTo(n,o){n!=null&&(this.cm6.scrollDOM.scrollLeft=n),o!=null&&(this.cm6.scrollDOM.scrollTop=o)}scrollIntoView(n,o){if(n){var s=this.indexFromPos(n);this.cm6.dispatch({effects:fe.scrollIntoView(s)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(n,o){this.cm6.dom.style.width=n+4+"px",this.cm6.dom.style.height=o+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(n){this.$lineHandleChanges&&this.$lineHandleChanges.push(n);for(let s in this.marks)this.marks[s].update(n.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(s=>s.map(n.changes)));var o=this.curOp=this.curOp||{};n.changes.iterChanges((s,c,f,m,v)=>{(o.$changeStart==null||o.$changeStart>f)&&(o.$changeStart=f),this.$lastChangeEndOffset=m;var b={text:v.toJSON()};o.lastChange?o.lastChange.next=o.lastChange=b:o.lastChange=o.change=b},!0),o.changeHandlers||(o.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var n=this.curOp=this.curOp||{};n.cursorActivityHandlers||(n.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(n,o){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var s=n()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return s}onBeforeEndOperation(){var n=this.curOp,o=!1;n&&(n.change&&hr(n.changeHandlers,this,n.change),n&&n.cursorActivity&&(hr(n.cursorActivityHandlers,this,null),n.isVimOp&&(o=!0)),this.curOp=null),o&&this.scrollIntoView()}moveH(n,o){if(o=="char"){var s=this.getCursor();this.setCursor(s.line,s.ch+n)}}setOption(n,o){switch(n){case"keyMap":this.state.keyMap=o;break;case"textwidth":this.state.textwidth=o;break}}getOption(n){switch(n){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(cr)==" ";case"indentUnit":return this.cm6.state.facet(cr).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(n){this.state.overwrite=n}getTokenTypeAt(n){var o,s=this.indexFromPos(n),c=xn(this.cm6.state,s),f=c?.resolve(s),m=((o=f?.type)===null||o===void 0?void 0:o.name)||"";return/comment/i.test(m)?"comment":/string/i.test(m)?"string":""}overWriteSelection(n){var o=this.cm6.state.doc,s=this.cm6.state.selection,c=s.ranges.map(f=>{if(f.empty){var m=f.to<o.length?o.sliceString(f.from,f.to+1):"";if(m&&!/\n/.test(m))return Le.range(f.from,f.to+1)}return f});this.cm6.dispatch({selection:Le.create(c,s.mainIndex)}),this.replaceSelection(n)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(n){var o=this.cm6.state.selection;this.virtualSelection=Le.create(o.ranges,o.mainIndex);for(var s=0;s<this.virtualSelection.ranges.length;s++){var c=this.virtualSelection.ranges[s];c&&(this.cm6.dispatch({selection:Le.create([c])}),n(),this.virtualSelection.ranges[s]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(n){return Na(this,n)}}j.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);j.Pos=Ve;j.StringStream=Po;j.commands={toggleLineComment:function(t){Io(t.cm6)},cursorCharLeft:function(t){Fo(t.cm6)},redo:function(t){pr(t,!1)},undo:function(t){pr(t,!0)},newlineAndIndent:function(t){Bo({state:t.cm6.state,dispatch:n=>vt(t,n)})},indentAuto:function(t){No(t.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};j.isWordChar=function(t){return hn.test(t)};j.keys=Sa;j.addClass=function(t,n){};j.rmClass=function(t,n){};j.e_preventDefault=function(t){t.preventDefault()};j.e_stop=function(t){var n,o;(n=t?.stopPropagation)===null||n===void 0||n.call(t),(o=t?.preventDefault)===null||o===void 0||o.call(t)};j.lookupKey=function(n,o,s){var c=j.keys[n];!c&&/^Arrow/.test(n)&&(c=j.keys[n.slice(5)]),c&&s(c)};j.on=Yr;j.off=Jr;j.signal=Gr;j.findMatchingTag=Ra;j.findEnclosingTag=Aa;j.keyName=void 0;function ei(t,n,o){var s=document.createElement("div");return s.appendChild(n),s}function ti(t,n){t.state.currentNotificationClose&&t.state.currentNotificationClose(),t.state.currentNotificationClose=n}function wa(t,n,o){ti(t,v);var s=ei(t,n,o&&o.bottom),c=!1,f,m=o&&typeof o.duration<"u"?o.duration:5e3;function v(){c||(c=!0,clearTimeout(f),s.remove(),ri(t,s))}return s.onclick=function(b){b.preventDefault(),v()},ni(t,s),m&&(f=setTimeout(v,m)),v}function ni(t,n){var o=t.state.dialog;t.state.dialog=n,n.style.flex="1",n&&o!==n&&(o&&o.contains(document.activeElement)&&t.focus(),o&&o.parentElement?o.parentElement.replaceChild(n,o):o&&o.remove(),j.signal(t,"dialog"))}function ri(t,n){t.state.dialog==n&&(t.state.dialog=null,j.signal(t,"dialog"))}function Ma(t,n,o,s){s||(s={}),ti(t,void 0);var c=ei(t,n,s.bottom),f=!1;ni(t,c);function m(b){if(typeof b=="string")v.value=b;else{if(f)return;f=!0,ri(t,c),t.state.dialog||t.focus(),s.onClose&&s.onClose(c)}}var v=c.getElementsByTagName("input")[0];return v&&(s.value&&(v.value=s.value,s.selectValueOnOpen!==!1&&v.select()),s.onInput&&j.on(v,"input",function(b){s.onInput(b,v.value,m)}),s.onKeyUp&&j.on(v,"keyup",function(b){s.onKeyUp(b,v.value,m)}),j.on(v,"keydown",function(b){s&&s.onKeyDown&&s.onKeyDown(b,v.value,m)||(b.keyCode==13&&o&&o(v.value),(b.keyCode==27||s.closeOnEnter!==!1&&b.keyCode==13)&&(v.blur(),j.e_stop(b),m()))}),s.closeOnBlur!==!1&&j.on(v,"blur",function(){setTimeout(function(){document.activeElement!==v&&m()})}),v.focus()),m}var Ea={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function La(t){return t&&t.bracketRegex||/[(){}[\]]/}function Ta(t,n,o,s,c){for(var f=c&&c.maxScanLineLength||1e4,m=c&&c.maxScanLines||1e3,v=[],b=La(c),S=o>0?Math.min(n.line+m,t.lastLine()+1):Math.max(t.firstLine()-1,n.line-m),M=n.line;M!=S;M+=o){var R=t.getLine(M);if(R){var A=o>0?0:R.length-1,E=o>0?R.length:-1;if(!(R.length>f))for(M==n.line&&(A=n.ch-(o<0?1:0));A!=E;A+=o){var T=R.charAt(A);if(b.test(T)){var D=Ea[T];if(D&&D.charAt(1)==">"==o>0)v.push(T);else if(v.length)v.pop();else return{pos:new Ve(M,A),ch:T}}}}}return M-o==(o>0?t.lastLine():t.firstLine())?!1:null}function Ra(t,n){return null}function Aa(t,n){var o,s,c=t.cm6.state,f=t.indexFromPos(n);if(f<c.doc.length){var m=c.sliceDoc(f,f+1);m=="<"&&f++}for(var v=xn(c,f),b=v?.resolve(f)||null;b;){if(((o=b.firstChild)===null||o===void 0?void 0:o.type.name)=="OpenTag"&&((s=b.lastChild)===null||s===void 0?void 0:s.type.name)=="CloseTag")return{open:mr(c.doc,b.firstChild),close:mr(c.doc,b.lastChild)};b=b.parent}}function mr(t,n){return{from:Pe(t,n.from),to:Pe(t,n.to)}}class Pa{constructor(n,o,s){this.cm=n,this.id=n.$mid++,this.offset=o,this.assoc=s,n.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(n){this.offset!=null&&(this.offset=n.mapPos(this.offset,this.assoc,qr.TrackDel))}}function Na(t,n){for(var o,s=n.column||t.getOption("textwidth")||80,c=n.allowMerge!=!1,f=Math.min(n.from,n.to),m=Math.max(n.from,n.to);f<=m;){var v=t.getLine(f);if(v.length>s){var b=T(v,s,5);if(b){var S=(o=/^\s*/.exec(v))===null||o===void 0?void 0:o[0];t.replaceRange(`
|
|
38
|
-
`+S,new Ve(f,b.start),new Ve(f,b.end))}m++}else if(c&&/\S/.test(v)&&f!=m){var M=t.getLine(f+1);if(M&&/\S/.test(M)){var R=v.replace(/\s+$/,""),A=M.replace(/^\s+/,""),E=R+" "+A,b=T(E,s,5);b&&b.start>R.length||E.length<s?(t.replaceRange(" ",new Ve(f,R.length),new Ve(f+1,M.length-A.length)),f--,m--):R.length<v.length&&t.replaceRange("",new Ve(f,R.length),new Ve(f,v.length))}}f++}return f;function T(D,z,W){if(!(D.length<z)){var ie=D.slice(0,z),Q=D.slice(z),de=/^(?:(\s+)|(\S+)(\s+))/.exec(Q),he=/(?:(\s+)|(\s+)(\S+))$/.exec(ie),J=0,ce=0;if(he&&!he[2]&&(J=z-he[1].length,ce=z),de&&!de[2]&&(J||(J=z),ce=z+de[1].length),J)return{start:J,end:ce};if(he&&he[2]&&he.index>W)return{start:he.index,end:he.index+he[2].length};if(de&&de[2])return J=z+de[2].length,{start:J,end:J+de[3].length}}}}let pn=To||(function(){let t={cursorBlinkRate:1200};return function(){return t}})();class Ba{constructor(n,o,s,c,f,m,v,b,S,M){this.left=n,this.top=o,this.height=s,this.fontFamily=c,this.fontSize=f,this.fontWeight=m,this.color=v,this.className=b,this.letter=S,this.partial=M}draw(){let n=document.createElement("div");return n.className=this.className,this.adjust(n),n}adjust(n){n.style.left=this.left+"px",n.style.top=this.top+"px",n.style.height=this.height+"px",n.style.lineHeight=this.height+"px",n.style.fontFamily=this.fontFamily,n.style.fontSize=this.fontSize,n.style.fontWeight=this.fontWeight,n.style.color=this.partial?"transparent":this.color,n.className=this.className,n.textContent=this.letter}eq(n){return this.left==n.left&&this.top==n.top&&this.height==n.height&&this.fontFamily==n.fontFamily&&this.fontSize==n.fontSize&&this.fontWeight==n.fontWeight&&this.color==n.color&&this.className==n.className&&this.letter==n.letter}}class Fa{constructor(n,o){this.view=n,this.rangePieces=[],this.cursors=[],this.cm=o,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=n.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),n.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let o=pn(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=o+"ms"}update(n){(n.selectionSet||n.geometryChanged||n.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),Ia(n)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:n}=this.view,o=[];for(let s of n.selection.ranges){let c=s==n.selection.main,f=Qa(this.cm,this.view,s,c);f&&o.push(f)}return{cursors:o}}drawSel({cursors:n}){if(n.length!=this.cursors.length||n.some((o,s)=>!o.eq(this.cursors[s]))){let o=this.cursorLayer.children;if(o.length!==n.length){this.cursorLayer.textContent="";for(const s of n)this.cursorLayer.appendChild(s.draw())}else n.forEach((s,c)=>s.adjust(o[c]));this.cursors=n}}destroy(){this.cursorLayer.remove()}}function Ia(t){return pn(t.startState)!=pn(t.state)}const Da={".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"}},$a=jr.highest(fe.theme(Da));function _a(t){let n=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Ao.LTR?n.left:n.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft*t.scaleX,top:n.top-t.scrollDOM.scrollTop*t.scaleY}}function Qa(t,n,o,s){var c,f,m,v;let b=o.head,S=!1,M=1,R=t.state.vim;if(R&&(!R.insertMode||t.state.overwrite)){if(S=!0,R.visualBlock&&!s)return null;o.anchor<o.head&&(b<n.state.doc.length&&n.state.sliceDoc(b,b+1))!=`
|
|
39
|
-
`&&b--,t.state.overwrite?M=.2:R.status&&(M=.5)}if(S){let E=b<n.state.doc.length&&n.state.sliceDoc(b,b+1);E&&/[\uDC00-\uDFFF]/.test(E)&&b>1&&(b--,E=n.state.sliceDoc(b,b+1));let T=n.coordsAtPos(b,1);if(!T)return null;let D=_a(n),z=n.domAtPos(b),W=z?z.node:n.contentDOM;for(W instanceof Text&&z.offset>=W.data.length&&!((c=W.parentElement)===null||c===void 0)&&c.nextSibling&&(W=(f=W.parentElement)===null||f===void 0?void 0:f.nextSibling,z={node:W,offset:0});z&&z.node instanceof HTMLElement;)W=z.node,z={node:z.node.childNodes[z.offset],offset:0};if(!(W instanceof HTMLElement)){if(!W.parentNode)return null;W=W.parentNode}let ie=getComputedStyle(W),Q=T.left,de=(v=(m=n).coordsForChar)===null||v===void 0?void 0:v.call(m,b);if(de&&(Q=de.left),!E||E==`
|
|
40
|
-
`||E=="\r")E=" ";else if(E==" "){E=" ";var A=n.coordsAtPos(b+1,-1);A&&(Q=A.left-(A.left-T.left)/parseInt(ie.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&b<n.state.doc.length-1&&(E+=n.state.sliceDoc(b+1,b+2));let he=T.bottom-T.top;return new Ba((Q-D.left)/n.scaleX,(T.top-D.top+he*(1-M))/n.scaleY,he*M/n.scaleY,ie.fontFamily,ie.fontSize,ie.fontWeight,ie.color,s?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,M!=1)}else return null}var Ka=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const Fe=xa(j),Va=250,ja=fe.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),qa=dt.fromClass(class{constructor(t){this.status="",this.query=null,this.decorations=Y.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=t;const n=this.cm=new j(t);Fe.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new Fa(t,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",o=>{n.state.vim&&(n.state.vim.mode=o.mode,o.subMode&&(n.state.vim.mode+=o.subMode==="linewise"?" line":" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():t.dispatch({effects:ii.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=o=>{Fe.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(t){var n;if((t.viewportChanged||t.docChanged)&&this.query&&this.highlight(this.query),t.docChanged&&this.cm.onChange(t),t.selectionSet&&this.cm.onSelectionChange(),t.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),t.transactions){for(let o of t.transactions)for(let s of o.effects)if(s.is(un))if(!((n=s.value)===null||n===void 0?void 0:n.forVim))this.highlight(null);else{let f=s.value.create();this.highlight(f)}}this.blockCursor.update(t)}updateClass(){const t=this.cm.state;!t.vim||t.vim.insertMode&&!t.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let t=this.cm.state.statusbar,n=this.cm.state.vim;if(!t||!n)return;let o=this.cm.state.dialog;if(o)o.parentElement!=t&&(t.textContent="",t.appendChild(o));else{t.textContent="";var s=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(s+="(C-O)"),this.statusButton.textContent=`--${s}--`,t.appendChild(this.statusButton),t.appendChild(this.spacer)}this.dom.textContent=n.status,t.appendChild(this.dom)}destroy(){Fe.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(t){if(this.query=t,!t)return this.decorations=Y.none;let{view:n}=this,o=new Co;for(let s=0,c=n.visibleRanges,f=c.length;s<f;s++){let{from:m,to:v}=c[s];for(;s<f-1&&v>c[s+1].from-2*Va;)v=c[++s].to;t.highlight(n.state,m,v,(b,S)=>{o.add(b,S,Ha)})}return this.decorations=o.finish()}handleKey(t,n){const o=this.cm;let s=o.state.vim;if(!s)return;const c=Fe.vimKeyFromEvent(t,s);if(j.signal(this.cm,"inputEvent",{type:"handleKey",key:c}),!c)return;if(c=="<Esc>"&&!s.insertMode&&!s.visualMode&&this.query){const v=s.searchState_;v&&(o.removeOverlay(v.getOverlay()),v.setOverlay(null))}if(c==="<C-c>"&&!j.isMac&&o.somethingSelected())return this.waitForCopy=!0,!0;s.status=(s.status||"")+c;let m=Fe.multiSelectHandleKey(o,c,"user");return s=Fe.maybeInitVimState_(o),!m&&s.insertMode&&o.state.overwrite&&(t.key&&t.key.length==1&&!/\n/.test(t.key)?(m=!0,o.overWriteSelection(t.key)):t.key=="Backspace"&&(m=!0,j.commands.cursorCharLeft(o))),m&&(j.signal(this.cm,"vim-keypress",c),t.preventDefault(),t.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!m}},{eventHandlers:{copy:function(t,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var o=this.cm,s=o.state.vim;s&&(s.insertMode?o.setSelection(o.getCursor(),o.getCursor()):o.operation(()=>{o.curOp&&(o.curOp.isVimOp=!0),Fe.handleKey(o,"<Esc>","user")}))}))},compositionstart:function(t,n){this.useNextTextInput=!0,j.signal(this.cm,"inputEvent",t)},compositionupdate:function(t,n){j.signal(this.cm,"inputEvent",t)},compositionend:function(t,n){j.signal(this.cm,"inputEvent",t)},keypress:function(t,n){j.signal(this.cm,"inputEvent",t),this.lastKeydown=="Dead"&&this.handleKey(t,n)},keydown:function(t,n){j.signal(this.cm,"inputEvent",t),this.lastKeydown=t.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(t,n))}},provide:()=>[fe.inputHandler.of((t,n,o,s)=>{var c,f,m=oi(t);if(!m)return!1;var v=(c=m.state)===null||c===void 0?void 0:c.vim,b=m.state.vimPlugin;if(v&&!v.insertMode&&!(!((f=m.curOp)===null||f===void 0)&&f.isVimOp)){if(s==="\0\0")return!0;if(j.signal(m,"inputEvent",{type:"text",text:s,from:n,to:o}),s.length==1&&b.useNextTextInput){if(v.expectLiteralNext&&t.composing)return b.compositionText=s,!1;if(b.compositionText){var S=b.compositionText;b.compositionText="";var M=t.state.selection.main.head,R=t.state.sliceDoc(M-S.length,M);if(S===R){var A=m.getCursor();m.replaceRange("",m.posFromIndex(M-S.length),A)}}return b.handleKey({key:s,preventDefault:()=>{},stopPropagation:()=>{}}),za(t),!0}}return!1})],decorations:t=>t.decorations});function za(t){var n=t.scrollDOM.parentElement;if(n){if(Ka){t.contentDOM.textContent="\0\0",t.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var o=t.scrollDOM.nextSibling,s=window.getSelection(),c=s&&{anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset};t.scrollDOM.remove(),n.insertBefore(t.scrollDOM,o);try{c&&s&&(s.setPosition(c.anchorNode,c.anchorOffset),c.focusNode&&s.extend(c.focusNode,c.focusOffset))}catch(f){console.error(f)}t.focus(),t.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const Ha=Y.mark({class:"cm-searchMatch"}),ii=Qt.define(),Wa=_t.define({create:()=>!1,update(t,n){for(let o of n.effects)o.is(ii)&&(t=o.value);return t},provide:t=>Vr.from(t,n=>n?Ua:null)});function Ua(t){let n=document.createElement("div");n.className="cm-vim-panel";let o=t.cm;return o.state.dialog&&n.appendChild(o.state.dialog),{top:!1,dom:n}}function Xa(t){let n=document.createElement("div");n.className="cm-vim-panel";let o=t.cm;return o.state.statusbar=n,o.state.vimPlugin.updateStatus(),{dom:n}}function gr(t={}){return[ja,qa,$a,t.status?Vr.of(Xa):Wa]}function oi(t){return t.cm||null}class Mn{constructor(n,o){this.yanchor=n,this.yhead=o}toJSON(){return{yanchor:ur(this.yanchor),yhead:ur(this.yhead)}}static fromJSON(n){return new Mn(yt(n.yanchor),yt(n.yhead))}}class Za{constructor(n,o){this.ytext=n,this.awareness=o,this.undoManager=new Xr(n)}toYPos(n,o=0){return fn(this.ytext,n,o)}fromYPos(n){const o=dn(yt(n),this.ytext.doc);if(o==null||o.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:o.index,assoc:o.assoc}}toYRange(n){const o=n.assoc,s=this.toYPos(n.anchor,o),c=this.toYPos(n.head,o);return new Mn(s,c)}fromYRange(n){const o=this.fromYPos(n.yanchor),s=this.fromYPos(n.yhead);return o.pos===s.pos?Le.cursor(s.pos,s.assoc):Le.range(o.pos,s.pos)}}const Ht=Kt.define({combine(t){return t[t.length-1]}}),mn=Sn.define();class Ya{constructor(n){this.view=n,this.conf=n.state.facet(Ht),this._observer=(o,s)=>{if(s.origin!==this.conf){const c=o.delta,f=[];let m=0;for(let v=0;v<c.length;v++){const b=c[v];b.insert!=null?f.push({from:m,to:m,insert:b.insert}):b.delete!=null?(f.push({from:m,to:m+b.delete,insert:""}),m+=b.delete):m+=b.retain}n.dispatch({changes:f,annotations:[mn.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(n){if(!n.docChanged||n.transactions.length>0&&n.transactions[0].annotation(mn)===this.conf)return;const o=this.conf.ytext;o.doc.transact(()=>{let s=0;n.changes.iterChanges((c,f,m,v,b)=>{const S=b.sliceString(0,b.length,`
|
|
41
|
-
`);c!==f&&o.delete(c+s,f-c),S.length>0&&o.insert(c+s,S),s+=S.length-(f-c)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const Ja=dt.fromClass(Ya),Ga=fe.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),es=Sn.define();class ts extends zr{constructor(n,o){super(),this.color=n,this.name=o}toDOM(){return an("span",[Ft("class","cm-ySelectionCaret"),Ft("style",`background-color: ${this.color}; border-color: ${this.color}`)],[Bt(""),an("div",[Ft("class","cm-ySelectionCaretDot")]),Bt(""),an("div",[Ft("class","cm-ySelectionInfo")],[Bt(this.name)]),Bt("")])}eq(n){return n.color===this.color}compare(n){return n.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}class ns{constructor(n){this.conf=n.state.facet(Ht),this._listener=({added:o,updated:s,removed:c},f,m)=>{o.concat(s).concat(c).findIndex(b=>b!==this.conf.awareness.doc.clientID)>=0&&n.dispatch({annotations:[es.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=_o.of([])}destroy(){this._awareness.off("change",this._listener)}update(n){const o=this.conf.ytext,s=o.doc,c=this.conf.awareness,f=[],m=this.conf.awareness.getLocalState();if(m!=null){const v=n.view.hasFocus&&n.view.dom.ownerDocument.hasFocus(),b=v?n.state.selection.main:null,S=m.cursor==null?null:yt(m.cursor.anchor),M=m.cursor==null?null:yt(m.cursor.head);if(b!=null){const R=fn(o,b.anchor),A=fn(o,b.head);(m.cursor==null||!fr(S,R)||!fr(M,A))&&c.setLocalStateField("cursor",{anchor:R,head:A})}else m.cursor!=null&&v&&c.setLocalStateField("cursor",null)}c.getStates().forEach((v,b)=>{if(b===c.doc.clientID)return;const S=v.cursor;if(S==null||S.anchor==null||S.head==null)return;const M=dn(S.anchor,s),R=dn(S.head,s);if(M==null||R==null||M.type!==o||R.type!==o)return;const{color:A="#30bced",name:E="Anonymous"}=v.user||{},T=v.user&&v.user.colorLight||A+"33",D=ya(M.index,R.index),z=ba(M.index,R.index),W=n.view.state.doc.lineAt(D),ie=n.view.state.doc.lineAt(z);if(W.number===ie.number)f.push({from:D,to:z,value:Y.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})});else{f.push({from:D,to:W.from+W.length,value:Y.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})}),f.push({from:ie.from,to:z,value:Y.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})});for(let Q=W.number+1;Q<ie.number;Q++){const de=n.view.state.doc.line(Q).from;f.push({from:de,to:de,value:Y.line({attributes:{style:`background-color: ${T}`,class:"cm-yLineSelection"}})})}}f.push({from:R.index,to:R.index,value:Y.widget({side:R.index-M.index>0?-1:1,block:!1,widget:new ts(A,E)})})}),this.decorations=Y.set(f,!0)}}const rs=dt.fromClass(ns,{decorations:t=>t.decorations}),is=()=>{let t=!0;return(n,o)=>{if(t){t=!1;try{n()}finally{t=!0}}else o!==void 0&&o()}};class os{constructor(n){this.undoManager=n}addTrackedOrigin(n){this.undoManager.addTrackedOrigin(n)}removeTrackedOrigin(n){this.undoManager.removeTrackedOrigin(n)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}}const Wt=Kt.define({combine(t){return t[t.length-1]}});class as{constructor(n){this.view=n,this.conf=n.state.facet(Wt),this._undoManager=this.conf.undoManager,this.syncConf=n.state.facet(Ht),this._beforeChangeSelection=null,this._mux=is(),this._onStackItemAdded=({stackItem:o,changedParentTypes:s})=>{s.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!o.meta.has(this)&&o.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:o})=>{const s=o.meta.get(this);if(s){const c=this.syncConf.fromYRange(s);n.dispatch(n.state.update({selection:c,effects:[fe.scrollIntoView(c)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(n){n.selectionSet&&(n.transactions.length===0||n.transactions[0].annotation(mn)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}const ss=dt.fromClass(as),ai=({state:t,dispatch:n})=>t.facet(Wt).undo()||!0,gn=({state:t,dispatch:n})=>t.facet(Wt).redo()||!0,ls=[{key:"Mod-z",run:ai,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:gn,preventDefault:!0},{key:"Mod-Shift-z",run:gn,preventDefault:!0}],cs=(t,n,{undoManager:o=new Xr(t)}={})=>{const s=new Za(t,n),c=[Ht.of(s),Ja];return n&&c.push(Ga,rs),o!==!1&&c.push(Wt.of(new os(o)),ss,fe.domEventHandlers({beforeinput(f,m){return f.inputType==="historyUndo"?ai(m):f.inputType==="historyRedo"?gn(m):!1}})),c};function us(t,n){if(!n.valid||!n.search)return 0;let o=0;const s=n.getCursor(t);for(;!s.next().done;)o+=1;return o}function fs(t){return JSON.stringify([t.search,t.caseSensitive,t.literal,t.regexp,t.wholeWord])}const ds=1,hs=2,ps=3;function vr(t){switch(t.toLowerCase()){case"@string":return ds;case"@preamble":return hs;case"@comment":return ps;default:return-1}}const ms=Qo.deserialize({version:14,states:"-UQYQPOOOhQPO'#CbOhQPO'#CpOpQPO'#CqOhQPO'#CyOOQO'#DY'#DYOOQO'#DO'#DOQYQPOOOOQO'#Cc'#CcOOQO'#Cn'#CnOxQPO,58|OxQPO,58|O}QPO,59[O}QPO,59[OOOO'#Cs'#CsO!]OQO'#CrOOOO'#Cv'#CvO!kOSO'#CuOOQO,59],59]O!yQWO,59eO!yQWO,59eOOQO-E6|-E6|OOQO'#Cd'#CdO#OQPO1G.hO#TQPO1G.hO#YOQO'#CgO#hO`O'#CiOOQO'#Ck'#CkOOQO'#Cf'#CfO#vQPO'#CeO$UQPO1G.vO$ZQPO1G.vOOOO'#Df'#DfOOOO'#DS'#DSO!]OQO,59^OOQO'#Ct'#CtOOQO,59^,59^O$`OSO'#CwOOOO'#Dg'#DgOOOO'#DT'#DTO!kOSO,59aOOQO'#Cx'#CxOOQO,59a,59aOOQO'#C{'#C{O$nQPO1G/PO$vQPO1G/PO}QPO7+$SO}QPO7+$SOOOO'#D^'#D^OOOO'#DP'#DPO%OOQO,59ROOQO,59R,59ROOOO'#Db'#DbOOOO'#DQ'#DQO%^O`O,59TOOQO,59T,59TO}QPO'#DRO%lQPO,59POOQO'#Cm'#CmOOQO7+$b7+$bOOQO'#Co'#CoOOOO-E7Q-E7QOOQO1G.x1G.xOOOO,59c,59cO%zOSO,59cOOOO-E7R-E7ROOQO1G.{1G.{O&YQPO7+$kO&bQPO7+$kOOQO7+$k7+$kO&jQPO7+$kO&rQPO7+$kO$UQPO<<GnO$ZQPO<<GnOOOO-E6}-E6}OOQO1G.m1G.mOOOO-E7O-E7OOOQO1G.o1G.oOOQO,59m,59mOOQO-E7P-E7POOOO1G.}1G.}OOQO'#C}'#C}O&zQPO'#C|OOQO,59p,59pOOQO<<HV<<HVO&YQPO<<HVOOQO-E7S-E7SO&jQPO<<HVOOQOAN=YAN=YO}QPO,59hOOQOAN=qAN=qP'PQPO'#DUOOQO1G/S1G/S",stateData:"'Z~O{OSSOS~OPPOQQORROnSO~O}WO!WXO~O}^O!W`O~O!OfO~O^lO}iO!OkO!TjO~O[pO}iO!RpO!SsO~O[vO!WuO!XyO![vO~O!]{O~O!P!OO~O!P!PO~O[!QO}iO!R!QO!S!TO~O[!UO}iO!T!XO!V!UO~O`!YO!SXX!XXX!^XX~O!S![O~O!X!^O~O[vO!WuO!X!aO![vO~O!S![O!^!eO~O!X!^O!^!hO~O[!QO}iO!R!QO!S!mO~O[!UO}iO!T!oO!V!UO~O`!YO!SXa!XXa!^Xa~O[vO!WuO!X!rO![vO~O!O!sO!S![O~O!S![O!^!wO~O!O!sO!X!^O~O!X!^O!^!yO~O!P!{O~O!O!sO~O[!R!V!R~",goto:"'_![PPPPPP!]!a!j!p#P#ZP#oP#oP#w$X$b!]!]$r$u$x$r%O%R%X!]P%_%e%l%s%y&P&V&]&c&mPPP&wPPP&{PPP'PPPP'T'XTTOVQYPQ[QRcSQgYRhZQn[Qo]Q!j!OQ!k!PR#O!{Ym[]!O!P!{R!p!Y[l[]!O!P!Y!{Sp_rS!Qi!ST!Uj!W]l[]!O!P!Y!{Q!]nQ!g|S!v!e!fQ!z!jR!|!wQZPQ]QRdSQ!]oQ!g}S!v!h!iQ!z!kR!|!yRbRR_RQt_R!`rRaRXvaux!bQzaR!dxQ|cR}dZ!u!e!h!w!y!}Z!t!e!h!w!y!}QVOReVQ!SiR!l!SQ!WjR!n!WQ!ZmR!q!ZQr_R!_rQxaQ!buT!cx!bQ!f|Q!i}T!x!f!iTUOVT!Ri!ST!Vj!WTq_rXwaux!b",nodeNames:"⚠ EntryType EntryType EntryType LineComment File StringEntry EntryBraceOpen StringName Value ValueAtom BracedValue Escape QuotedValue Number StringRef Concat EntryBraceClose EntryParenOpen EntryParenClose PreambleEntry CommentEntry CommentBracedBlock CommentBraceOpen CommentBraceClose CommentParenBlock CommentParenOpen CommentParenValue CommentParenClose Entry EntryType EntryKey Field FieldName",maxTerm:60,skippedNodes:[0,4],repeatNodeCount:7,tokenData:"=i~RtOX#cXY'eYZ'eZ]#c]^'e^p#cpq'eqr#crs({st)ttu#cuv*uvx#cxy0xyz1kz|#c|}2^}!Q#c!Q![3_![!_#c!_!`6w!`!b#c!b!c7x!c!}:[!}#O#c#O#P<Q#P#R#c#R#S:[#S#T#c#T#o:[#o#p<k#p#q#c#q#r=R#r;'S#c;'S;=`'_<%lO#cf#l[![S!RQ!V`Or#crs$bsx#cxz&hz#O#c#P#o#c#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cU$iY![S!RQOx$bxz%Xz#O$b#P#o$b#o#p%v#p#q$b#q#r%v#r;'S$b;'S;=`&b<%lO$bQ%^U!RQO#O%X#P#o%X#p#q%X#r;'S%X;'S;=`%p<%lO%XQ%sP;=`<%l%XS%{T![SOx%vz#O%v#P;'S%v;'S;=`&[<%lO%vS&_P;=`<%l%vU&eP;=`<%l$bb&oW!RQ!V`Or&hrs%Xs#O&h#P#o&h#p#q&h#r;'S&h;'S;=`'X<%lO&hb'[P;=`<%l&hf'bP;=`<%l#co'pc![S{X!RQ!V`OX#cXY'eYZ'eZ]#c]^'e^p#cpq'eqr#crs$bsx#cxz&hz#O#c#P#o#c#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cg)UY!Ta![S!RQOx$bxz%Xz#O$b#P#o$b#o#p%v#p#q$b#q#r%v#r;'S$b;'S;=`&b<%lO$bg*P[`P![S!RQ!V`Or#crs$bsx#cxz&hz#O#c#P#o#c#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#co+Q_SX![S!RQ!V`OY*uYZ#cZr*urs,Psx*uxz/jz#O*u#O#P-{#P#o*u#o#p.j#p#q*u#q#r.j#r;'S*u;'S;=`0r<%lO*u_,Y]SX![S!RQOY,PYZ$bZx,Pxz-Rz#O,P#O#P-{#P#o,P#o#p.j#p#q,P#q#r.j#r;'S,P;'S;=`/d<%lO,PZ-YZSX!RQOY-RYZ%XZ#O-R#O#P-{#P#o-R#o#p-{#p#q-R#q#r-{#r;'S-R;'S;=`.d<%lO-RX.QSSXOY-{Z;'S-{;'S;=`.^<%lO-{X.aP;=`<%l-{Z.gP;=`<%l-R].qXSX![SOY.jYZ%vZx.jxz-{z#O.j#O#P-{#P;'S.j;'S;=`/^<%lO.j]/aP;=`<%l.j_/gP;=`<%l,Pk/s]SX!RQ!V`OY/jYZ&hZr/jrs-Rs#O/j#O#P-{#P#o/j#o#p-{#p#q/j#q#r-{#r;'S/j;'S;=`0l<%lO/jk0oP;=`<%l/jo0uP;=`<%l*ug1RW!WT!RQ!V`Or&hrs%Xs#O&h#P#o&h#p#q&h#r;'S&h;'S;=`'X<%lO&hg1tW!XT!RQ!V`Or&hrs%Xs#O&h#P#o&h#p#q&h#r;'S&h;'S;=`'X<%lO&hg2i[!^P![S!RQ!V`Or#crs$bsx#cxz&hz#O#c#P#o#c#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#co3lg^P!]W![S!RQ!V`Or#crs$bsx#cxz&hz}#c}!O5T!O!P5T!P!Q5T!Q![3_![!]5T!]!c#c!c!}5T!}#O#c#P#R#c#R#S5T#S#T#c#T#o5T#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cn5`g!]W![S!RQ!V`Or#crs$bsx#cxz&hz}#c}!O5T!O!P5T!P!Q5T!Q![5T![!]5T!]!c#c!c!}5T!}#O#c#P#R#c#R#S5T#S#T#c#T#o5T#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cg7S[!PP![S!RQ!V`Or#crs$bsx#cxz&hz#O#c#P#o#c#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cg8R_![S!RQ!V`Or#crs$bsx#cxz&hz!c#c!c!}9Q!}#O#c#P#T#c#T#o9Q#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#cg9]_nP![S!RQ!V`Or#crs$bsx#cxz&hz!c#c!c!}9Q!}#O#c#P#T#c#T#o9Q#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#co:ig!]W!OP![S!RQ!V`Or#crs$bsx#cxz&hz}#c}!O:[!O!P5T!P!Q5T!Q![:[![!]5T!]!c#c!c!}:[!}#O#c#P#R#c#R#S:[#S#T#c#T#o:[#o#p%v#p#q#c#q#r%v#r;'S#c;'S;=`'_<%lO#c~<TRO;'S<^;'S;=`<c;=`O<^~<cO[~~<hP[~;=`<%l<^g<rT}c![SOx%vz#O%v#P;'S%v;'S;=`&[<%lO%vV=YT!SR![SOx%vz#O%v#P;'S%v;'S;=`&[<%lO%v",tokenizers:[0,1,2,3,4],topRules:{File:[0,5]},specialized:[{term:30,get:(t,n)=>vr(t)<<1,external:vr}],tokenPrec:282}),gs=Ko.define({name:"bibtex",parser:ms.configure({props:[Vo.add({Entry:t=>t.baseIndent+t.unit,StringEntry:t=>t.baseIndent+t.unit,PreambleEntry:t=>t.baseIndent+t.unit,BracedValue:t=>t.baseIndent+t.unit}),jo.add({Entry:ut,StringEntry:ut,PreambleEntry:ut,CommentBracedBlock:ut,CommentParenBlock:ut,BracedValue:ut}),qo({EntryType:ye.definitionKeyword,StringEntryType:ye.definitionKeyword,PreambleEntryType:ye.definitionKeyword,CommentEntryType:ye.definitionKeyword,EntryKey:ye.atom,FieldName:ye.propertyName,StringName:ye.propertyName,StringRef:ye.variableName,Number:ye.number,Concat:ye.operator,BracedValue:ye.string,QuotedValue:ye.string,Escape:ye.escape,LineComment:ye.lineComment,CommentEntry:ye.blockComment,CommentBracedBlock:ye.blockComment,CommentParenBlock:ye.blockComment})]}),languageData:{commentTokens:{line:"%"},closeBrackets:{brackets:["{",'"']}}}),vs={author:"authors",editor:"editors",journal:"journals",journaltitle:"journals",shortjournal:"journals",publisher:"publishers",origpublisher:"publishers",school:"schools",institution:"institutions",organization:"organizations",address:"addresses",location:"addresses",origlocation:"addresses",year:"years",origyear:"years"};function si(t){const n=[];let o=0;for(let s=0;s<t.length;s++){const c=t[s];if(c==="\\"){s++;continue}if(c==="{"){o++;continue}if(c==="}"){o=Math.max(0,o-1);continue}if(o!==0||t.slice(s,s+3).toLowerCase()!=="and")continue;const f=t[s-1],m=t[s+3];if(!f||!/\s/.test(f)||m!==void 0&&!/\s/.test(m))continue;let v=s;for(;v>0&&/\s/.test(t[v-1]);)v--;let b=s+3;for(;b<t.length&&/\s/.test(t[b]);)b++;n.push({from:v,to:b}),s+=2}return n}function li(t){const n=si(t),o=n.at(-1),s=o&&t.slice(o.to).trim()===""?o.from:t.length,c=[];let f=0;for(const v of n){if(v.from>=s)break;const b=t.slice(f,v.from).trim();b&&c.push(b),f=v.to}const m=t.slice(f,s).trim();return m&&c.push(m),c}function ys(t){const n=t.trim();return n.startsWith("{")&&n.endsWith("}")||n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).trim():n}function bs(t){const n={authors:new Set,editors:new Set,journals:new Set,publishers:new Set,schools:new Set,institutions:new Set,organizations:new Set,addresses:new Set,years:new Set,keys:new Set,byField:new Map},o=Vt(t),s=t.doc;return o.cursor().iterate(c=>{if(c.name!=="Entry")return;const f=c.node,m=f.getChild("EntryKey");m&&n.keys.add(s.sliceString(m.from,m.to));for(const v of f.getChildren("Field")){const b=v.getChild("FieldName"),S=v.getChild("Value");if(!b||!S||S.getChild("Concat"))continue;const M=s.sliceString(b.from,b.to).toLowerCase(),R=ys(s.sliceString(S.from,S.to));if(!R)continue;n.byField.has(M)||n.byField.set(M,new Set),n.byField.get(M).add(R);const A=vs[M];if(A==="authors"||A==="editors")for(const E of li(R))n[A].add(E);else A&&n[A].add(R)}return!1}),n}const En={syntaxError:()=>"Syntax error",duplicatePerson:(t,n)=>`Duplicate name in ${t}: ${n}`,unknownEntryType:t=>`Unknown entry type: @${t}`,duplicateEntryKey:t=>`Duplicate entry key: ${t}`,duplicateField:t=>`Duplicate field '${t}' in entry`,unknownField:t=>`Unknown field: ${t}`,invalidFieldValue:t=>`Syntax error in value for field '${t}'`,emptyFieldValue:t=>`Empty value for field '${t}'`,verifyInheritedFields:(t,n)=>`Verify '${t}' provides: ${n}`,missingRequiredFields:t=>`Missing required fields: ${t}`,missingRecommendedFields:t=>`Recommended fields missing: ${t}`,entryDescription:t=>`BibTeX entry type @${t}.`,fieldDescription:t=>`${t} is a BibTeX field.`,requiredFields:t=>`Required: ${t}`,optionalFields:t=>`Optional: ${t}`,exampleLabel:()=>"Example",noteLabel:()=>"Note",authorsNote:()=>"Use “and” to separate multiple authors or editors.",pagesNote:()=>"Use a double dash (--) for a page range.",monthNote:()=>"Use a three-letter abbreviation without quotes."},ci=new Set(["remote-id","external-id"]),ui=new Set(["article","book","mvbook","inbook","bookinbook","suppbook","booklet","collection","mvcollection","incollection","suppcollection","manual","misc","online","webpage","patent","periodical","suppperiodical","proceedings","mvproceedings","inproceedings","conference","reference","mvreference","inreference","report","techreport","thesis","mastersthesis","phdthesis","unpublished","software","dataset","letter","set","xdata"]),Ln=new Set(["abstract","addendum","address","afterword","annotation","annote","annotator","archiveprefix","author","authortype","bookauthor","bookpagination","booksubtitle","booktitle","booktitleaddon","chapter","commentator","crossref","date","doi","edition","editor","editora","editorb","editorc","editortype","editoratype","editorbtype","editorctype","eid","entryset","eprint","eprintclass","eprinttype","eventdate","eventtitle","eventtitleaddon","execute","file","foreword","gender","holder","howpublished","hyphenation","indexsorttitle","indextitle","institution","introduction","isan","isbn","ismn","isrn","issn","issue","issuesubtitle","issuetitle","iswc","journal","journalsubtitle","journaltitle","key","keywords","label","langid","langidopts","language","library","location","mainsubtitle","maintitle","maintitleaddon","month","nameaddon","note","number","organization","origdate","origlanguage","origlocation","origpublisher","origtitle","origyear","options","pages","pagetotal","pagination","part","presort","primaryclass","publisher","pubstate","related","relatedoptions","relatedstring","relatedtype","reprinttitle","school","series","shortauthor","shorteditor","shorthand","shorthandintro","shortjournal","shortseries","shorttitle","sortkey","sortname","sortshorthand","sorttitle","sortyear","subtitle","title","titleaddon","translator","type","url","urldate","usera","userb","userc","userd","usere","userf","venue","verba","verbb","verbc","version","volume","volumes","xdata","xref","year"]),Tn={article:{required:["author","title"],alternatives:[["date","year"],{fields:["journaltitle","journal"],severity:"warning"}],optional:["translator","editor","subtitle","titleaddon","volume","number","eid","issue","pages","note","issn","doi","eprint","url","urldate","series"]},book:{required:["title"],alternatives:[["date","year"],{fields:["author","editor"],severity:"warning"}],optional:["publisher","location","address","edition","volume","volumes","series","number","isbn","pagetotal","note","doi","url","urldate","subtitle","titleaddon","maintitle","mainsubtitle","translator","commentator","annotator","introduction","foreword","afterword"]},mvbook:{required:["title","volumes"],alternatives:[["author","editor"],["date","year"]],optional:["publisher","location","edition","series","number","isbn","note","subtitle","titleaddon"]},inbook:{required:["title","booktitle"],alternatives:[["author","editor"],["date","year"]],optional:["bookauthor","editor","pages","chapter","publisher","location","edition","volume","series","number","maintitle","note","doi","url","urldate"]},booklet:{required:["title"],alternatives:[["author","editor"]],optional:["howpublished","location","date","year","month","note","url"]},collection:{required:["title"],alternatives:[["date","year"],{fields:["editor"],severity:"warning"}],optional:["publisher","location","edition","volume","volumes","series","number","isbn","note","subtitle","titleaddon"]},mvcollection:{required:["editor","title"],alternatives:[["date","year"]],optional:["publisher","location","edition","volumes","series","number","isbn","note"]},incollection:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","location","edition","volume","series","number","maintitle","note","doi","url"]},inproceedings:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","organization","location","venue","eventdate","eventtitle","series","volume","number","note","doi","url"]},conference:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","organization","location","series","volume","number","note"]},proceedings:{required:["title"],alternatives:[["date","year"]],optional:["editor","publisher","organization","location","venue","eventdate","eventtitle","series","volume","number","note"]},manual:{required:["title"],optional:["author","editor","organization","edition","location","date","year","month","note","url"]},misc:{required:["title"],optional:["author","editor","howpublished","date","year","month","note","url","urldate"]},online:{required:["title"],alternatives:[["date","year"],{fields:["url","doi","eprint"],severity:"warning"}],optional:["author","editor","month","urldate","note","organization","version"]},webpage:{required:["title","url"],optional:["author","date","year","urldate","note"]},patent:{required:["author","title","number"],alternatives:[["date","year"]],optional:["holder","type","location","note","url"]},periodical:{required:["title"],alternatives:[["date","year"],{fields:["editor"],severity:"warning"}],optional:["subtitle","issuetitle","issuesubtitle","series","volume","number","issue","issn","note"]},thesis:{required:["author","title","type","institution"],alternatives:[["date","year"]],optional:["location","note","url","doi","school"]},phdthesis:{required:["author","title","school"],alternatives:[["date","year"]],optional:["location","address","type","note","url","doi","month"]},mastersthesis:{required:["author","title","school"],alternatives:[["date","year"]],optional:["location","address","type","note","url","doi","month"]},report:{required:["author","title","type","institution"],alternatives:[["date","year"]],optional:["number","location","note","url","doi"]},techreport:{required:["author","title","institution"],alternatives:[["date","year"]],optional:["type","number","location","address","note","url","month"]},unpublished:{required:["author","title"],alternatives:[["date","year"]],optional:["note","month","url"]},dataset:{required:["title"],alternatives:[["date","year"]],optional:["author","editor","publisher","version","doi","url","urldate","note"]},software:{required:["title"],alternatives:[["date","year"]],optional:["author","editor","publisher","version","url","urldate","note"]},set:{required:["entryset"],optional:[]}},ks={checkRequiredFields:!0,checkUnknownFields:!0,checkDuplicateKeys:!0,checkFieldSyntax:!0,checkEntryTypes:!0},Cs=500;function Os(t,n,o){const s=new Set;t.cursor().iterate(c=>{if(!c.type.isError||s.has(c.from))return;s.add(c.from);const f=c.to>c.from?c.to:c.from+1;n.push({from:c.from,to:f,severity:"error",message:o.syntaxError(),source:"BibTeX"})})}function xs(t,n,o,s){const c=fi(n.sliceString(t.valueFrom,t.valueTo)),f=new Set;for(const m of li(c)){const v=m.toLowerCase();f.has(v)?o.push({from:t.valueFrom,to:t.valueTo,severity:"warning",message:s.duplicatePerson(t.name,m),source:"BibTeX"}):f.add(v)}}function Ss(t={}){const{messages:n=En,...o}=t,s={...ks,...o};return c=>{const f=[],m=c.state.doc,v=xn(c.state,m.length,Cs)??Vt(c.state),b=v.length>=m.length,S=new Map;return v.cursor().iterate(M=>{if(M.name==="Entry")return ws(M.node,m,f,S,s,b,n),!1}),s.checkFieldSyntax&&b&&Os(v,f,n),f}}function ws(t,n,o,s,c,f,m){const v=t.getChild("EntryType"),b=t.getChild("EntryKey");if(!v)return;const M=n.sliceString(v.from,v.to).replace(/^@/,"").toLowerCase();if(c.checkEntryTypes&&!ui.has(M)&&o.push({from:v.from,to:v.to,severity:"warning",message:m.unknownEntryType(M),source:"BibTeX"}),c.checkDuplicateKeys&&b){const E=n.sliceString(b.from,b.to).trim();if(E){const T=s.get(E);T?(o.push({from:b.from,to:b.to,severity:"error",message:m.duplicateEntryKey(E),source:"BibTeX"}),T.flagged||(o.push({from:T.from,to:T.to,severity:"error",message:m.duplicateEntryKey(E),source:"BibTeX"}),T.flagged=!0)):s.set(E,{from:b.from,to:b.to,flagged:!1})}}const R=Ms(t,n),A=new Set(R.map(E=>E.name.toLowerCase()));if(c.checkRequiredFields&&f){const E=Tn[M];if(E){const T=["crossref","xref","xdata","related"].find(D=>A.has(D));Es(t,A,E,o,T,m)}}if(c.checkUnknownFields||c.checkFieldSyntax||c.checkDuplicateKeys){const E=new Map;for(const T of R){const D=T.name.toLowerCase();ci.has(D)||(c.checkDuplicateKeys&&(E.has(D)?o.push({from:T.nameFrom,to:T.nameTo,severity:"warning",message:m.duplicateField(T.name),source:"BibTeX"}):E.set(D,T.nameFrom),(D==="author"||D==="editor")&&xs(T,n,o,m)),c.checkUnknownFields&&!Ln.has(D)&&o.push({from:T.nameFrom,to:T.nameTo,severity:"warning",message:m.unknownField(T.name),source:"BibTeX"}),c.checkFieldSyntax&&(T.hasError?o.push({from:T.valueFrom,to:T.valueTo,severity:"error",message:m.invalidFieldValue(T.name),source:"BibTeX"}):T.isEmpty&&o.push({from:T.valueFrom,to:T.valueTo,severity:"warning",message:m.emptyFieldValue(T.name),source:"BibTeX"})))}}}function Ms(t,n){const o=[];for(const s of t.getChildren("Field")){const c=s.getChild("FieldName"),f=s.getChild("Value");if(!c)continue;const m=f?f.from:c.to,v=f?f.to:c.to,b=f?n.sliceString(f.from,f.to):"";o.push({name:n.sliceString(c.from,c.to),nameFrom:c.from,nameTo:c.to,valueFrom:m,valueTo:v,isEmpty:!f||fi(b).trim()==="",hasError:f?Ls(f):!1})}return o}function Es(t,n,o,s,c,f){const m=[],v=[];for(const b of o.required)n.has(b)||m.push(b);if(o.alternatives)for(const b of o.alternatives){const S=Array.isArray(b)?b:b.fields,M=Array.isArray(b)?"error":b.severity;if(!S.some(R=>n.has(R))){const R=S.join(" or ");M==="warning"?v.push(R):m.push(R)}}if(c){if(m.length>0||v.length>0){const b=[...m,...v];s.push({from:t.from,to:t.to,severity:"info",message:f.verifyInheritedFields(c,b.join(", ")),source:"BibTeX"})}return}m.length>0&&s.push({from:t.from,to:t.to,severity:"error",message:f.missingRequiredFields(m.join(", ")),source:"BibTeX"}),v.length>0&&s.push({from:t.from,to:t.to,severity:"warning",message:f.missingRecommendedFields(v.join(", ")),source:"BibTeX"})}function Ls(t){let n=!1;return t.cursor().iterate(o=>{if(n)return!1;if(o.type.isError)return n=!0,!1}),n}function fi(t){const n=t.trim();return n.startsWith("{")&&n.endsWith("}")||n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n}const Ts={article:`@article{key,
|
|
42
|
-
author = {John Doe},
|
|
43
|
-
title = {Sample Article},
|
|
44
|
-
journal = {Journal Name},
|
|
45
|
-
year = {2023}
|
|
46
|
-
}`,book:`@book{key,
|
|
47
|
-
author = {Jane Smith},
|
|
48
|
-
title = {Book Title},
|
|
49
|
-
publisher = {Publisher},
|
|
50
|
-
year = {2023}
|
|
51
|
-
}`,inproceedings:`@inproceedings{key,
|
|
52
|
-
author = {Author Name},
|
|
53
|
-
title = {Paper Title},
|
|
54
|
-
booktitle = {Conference Proceedings},
|
|
55
|
-
year = {2023}
|
|
56
|
-
}`},Rs={author:"John Doe and Jane Smith",title:"A Great Discovery in Science",journal:"Nature",year:"2023",publisher:"Academic Press",booktitle:"Proceedings of the International Conference",editor:"John Editor and Jane Editor",pages:"123--145",volume:"42",number:"3",month:"jan",note:"In press",doi:"10.1000/182",url:"https://example.com/paper.pdf",urldate:"2023-12-01",address:"New York, NY",edition:"2nd",series:"Lecture Notes in Computer Science",school:"MIT",institution:"Stanford University",organization:"IEEE",type:"PhD thesis",howpublished:"Self-published",chapter:"7",key:"Anonymous99",crossref:"conf2023",isbn:"978-0-123456-78-9",issn:"1234-5678",keywords:"machine learning, artificial intelligence",abstract:"This paper presents..."};function As(t){const n=Tn[t];if(!n)return{requiredFields:[],optionalFields:[]};const o=[...n.required];for(const s of n.alternatives??[]){const c=Array.isArray(s)?s:s.fields;o.push(c.join(" or "))}return{requiredFields:o,optionalFields:n.optional}}function Ps(t,n,o=1){const s=Vt(t).resolveInner(n,o);if(s.name==="EntryType"){const m=t.sliceDoc(s.from+1,s.to).toLowerCase();return ui.has(m)?{kind:"entry",entryType:m,from:s.from,to:s.to,...As(m),example:Ts[m]}:null}if(s.name!=="FieldName")return null;const c=t.sliceDoc(s.from,s.to).toLowerCase();if(ci.has(c)||!Ln.has(c))return null;const f=c==="author"||c==="editor"?"authors":c==="pages"?"pages":c==="month"?"month":void 0;return{kind:"field",field:c,from:s.from,to:s.to,example:Rs[c],note:f}}function je(t,n,o){const s=document.createElement("div");s.className=n,s.textContent=o,t.appendChild(s)}function Ns(t,n,o){je(t,"cm-bibtex-tooltip-example-label",o.exampleLabel());const s=document.createElement("pre");s.className="cm-bibtex-tooltip-example",s.textContent=n,t.appendChild(s)}function Bs(t,n){return{pos:t.from,end:t.to,above:!0,create(){const o=document.createElement("div");return o.className="cm-bibtex-tooltip",je(o,"cm-bibtex-tooltip-description",n.entryDescription(t.entryType)),t.requiredFields.length>0&&je(o,"cm-bibtex-tooltip-required",n.requiredFields(t.requiredFields.join(", "))),t.optionalFields.length>0&&je(o,"cm-bibtex-tooltip-optional",n.optionalFields(t.optionalFields.join(", "))),t.example&&Ns(o,t.example,n),{dom:o}}}}function Fs(t,n){return{pos:t.from,end:t.to,above:!0,create(){const o=document.createElement("div");return o.className="cm-bibtex-tooltip",je(o,"cm-bibtex-tooltip-field-name",t.field),je(o,"cm-bibtex-tooltip-description",n.fieldDescription(t.field)),t.example&&je(o,"cm-bibtex-tooltip-example-inline",`${n.exampleLabel()}: ${t.example}`),t.note==="authors"&&je(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.authorsNote()}`),t.note==="pages"&&je(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.pagesNote()}`),t.note==="month"&&je(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.monthNote()}`),{dom:o}}}}function di(t=En){return Hr((n,o,s)=>{const c=Ps(n.state,o,s);return c?c.kind==="entry"?Bs(c,t):Fs(c,t):null})}di();const Is=["article","book","booklet","conference","inbook","incollection","inproceedings","manual","mastersthesis","misc","online","phdthesis","proceedings","techreport","unpublished","webpage"],Ds=Array.from(Ln),$s=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],_s=["Nature","Science","Cell","PNAS","J. Am. Chem. Soc.","Phys. Rev. Lett.","IEEE Trans.","ACM Trans.","Commun. ACM"],Qs=[oe(`@article{#{key},
|
|
57
|
-
author = {#{author}},
|
|
58
|
-
title = {#{title}},
|
|
59
|
-
journaltitle = {#{journal}},
|
|
60
|
-
date = {#{year}},
|
|
61
|
-
volume = {#{volume}},
|
|
62
|
-
number = {#{number}},
|
|
63
|
-
pages = {#{pages}}
|
|
64
|
-
}`,{label:"@article",type:"keyword",detail:"Journal article"}),oe(`@book{#{key},
|
|
65
|
-
author = {#{author}},
|
|
66
|
-
title = {#{title}},
|
|
67
|
-
publisher = {#{publisher}},
|
|
68
|
-
date = {#{year}},
|
|
69
|
-
location = {#{location}}
|
|
70
|
-
}`,{label:"@book",type:"keyword",detail:"Book"}),oe(`@inproceedings{#{key},
|
|
71
|
-
author = {#{author}},
|
|
72
|
-
title = {#{title}},
|
|
73
|
-
booktitle = {#{booktitle}},
|
|
74
|
-
date = {#{year}},
|
|
75
|
-
pages = {#{pages}}
|
|
76
|
-
}`,{label:"@inproceedings",type:"keyword",detail:"Conference paper"}),oe(`@incollection{#{key},
|
|
77
|
-
author = {#{author}},
|
|
78
|
-
title = {#{title}},
|
|
79
|
-
booktitle = {#{booktitle}},
|
|
80
|
-
editor = {#{editor}},
|
|
81
|
-
publisher = {#{publisher}},
|
|
82
|
-
date = {#{year}},
|
|
83
|
-
pages = {#{pages}}
|
|
84
|
-
}`,{label:"@incollection",type:"keyword",detail:"Book chapter"}),oe(`@thesis{#{key},
|
|
85
|
-
author = {#{author}},
|
|
86
|
-
title = {#{title}},
|
|
87
|
-
type = {#{phdthesis}},
|
|
88
|
-
institution = {#{institution}},
|
|
89
|
-
date = {#{year}}
|
|
90
|
-
}`,{label:"@thesis",type:"keyword",detail:"Thesis (biblatex)"}),oe(`@online{#{key},
|
|
91
|
-
author = {#{author}},
|
|
92
|
-
title = {#{title}},
|
|
93
|
-
url = {#{url}},
|
|
94
|
-
urldate = {#{urldate}},
|
|
95
|
-
date = {#{year}}
|
|
96
|
-
}`,{label:"@online",type:"keyword",detail:"Online resource"}),oe(`@misc{#{key},
|
|
97
|
-
title = {#{title}},
|
|
98
|
-
author = {#{author}},
|
|
99
|
-
date = {#{year}},
|
|
100
|
-
note = {#{note}}
|
|
101
|
-
}`,{label:"@misc",type:"keyword",detail:"Miscellaneous"}),oe(`@manual{#{key},
|
|
102
|
-
title = {#{title}},
|
|
103
|
-
author = {#{author}},
|
|
104
|
-
organization = {#{organization}},
|
|
105
|
-
date = {#{year}}
|
|
106
|
-
}`,{label:"@manual",type:"keyword",detail:"Manual"}),oe(`@techreport{#{key},
|
|
107
|
-
author = {#{author}},
|
|
108
|
-
title = {#{title}},
|
|
109
|
-
institution = {#{institution}},
|
|
110
|
-
date = {#{year}},
|
|
111
|
-
number = {#{number}}
|
|
112
|
-
}`,{label:"@techreport",type:"keyword",detail:"Technical report"})],Ks=new Set(["Value","ValueAtom","BracedValue","QuotedValue","Number","StringRef"]),Vs={author:"authors",editor:"editors",journal:"journals",journaltitle:"journals",shortjournal:"journals",publisher:"publishers",school:"schools",institution:"institutions",organization:"organizations",address:"addresses",location:"addresses",year:"years",date:"years",origyear:"years"};function bt(t,n){let o=t;for(;o;){if(o.name===n)return o;o=o.parent}return null}function js(t,n){let o=t;for(;o;){if(n.has(o.name))return o;o=o.parent}return null}function qs(t){const n=new Set(["BracedValue","QuotedValue","Number","StringRef"]);let o=t;for(;o;){if(n.has(o.name))return o;if(o.name==="Value"||o.name==="Field"||o.name==="Entry")return null;o=o.parent}return null}function zs(t,n){const o=bt(t,"Field");if(!o)return null;const s=o.getChild("FieldName");return s?n.sliceString(s.from,s.to).toLowerCase():null}function Hs(t,n){const o=bt(t,"Entry");if(!o)return null;const s=o.getChild("EntryType");return s?n.sliceString(s.from,s.to).replace(/^@/,"").toLowerCase():null}function Ws(t,n){const o=new Set,s=bt(t,"Entry");if(!s)return o;for(const c of s.getChildren("Field")){const f=c.getChild("FieldName");f&&o.add(n.sliceString(f.from,f.to).toLowerCase())}return o}function yr(t){const n=t.matchBefore(/@[a-zA-Z]*/);if(!n||n.from===n.to&&!t.explicit)return null;const o=t.state.doc.lineAt(n.from).from,c=t.state.sliceDoc(o,n.from).trim()==="",f=Is.map(v=>({label:"@"+v,type:"keyword",apply:"@"+v,boost:1})),m=c?[...f,...Qs.map(v=>({...v,boost:.5}))]:f;return{from:n.from,options:m,validFor:/^@?[a-zA-Z]*$/}}function Us(t,n){const o=t.matchBefore(/[a-zA-Z_]*/);if(!o)return null;const s=t.state.doc,c=Ws(n,s),f=Hs(n,s),m=f?Tn[f]:void 0,v=new Set(m?.required??[]),b=new Set(m?.optional??[]);if(m?.alternatives)for(const M of m.alternatives){const R=Array.isArray(M)?M:M.fields;for(const A of R)v.add(A)}const S=[];for(const M of Ds){if(c.has(M.toLowerCase()))continue;let R=.5;v.has(M)?R=2:b.has(M)&&(R=1),S.push(oe(`${M} = {\${value}}`,{label:M,type:"property",boost:R}))}return{from:o.from,options:S,validFor:/^[a-zA-Z_]*$/}}function Xs(t,n){const o=t.state.doc,s=zs(n,o);if(!s)return null;const c=s==="author"||s==="editor",f=qs(n);if(c&&(!f||f.name!=="BracedValue"&&f.name!=="QuotedValue"))return null;let m,v=t.pos;if(c&&f){const E=f.from+1,T=f.to-(o.sliceString(f.to-1,f.to)===(f.name==="BracedValue"?"}":'"')?1:0);if(t.pos<E||t.pos>T)return null;const D=si(o.sliceString(E,T)),z=t.pos-E,W=[...D].reverse().find(Q=>Q.to<=z),ie=D.find(Q=>Q.from>=z);m=E+(W?.to??0),v=E+(ie?.from??T-E)}else if(f&&(f.name==="BracedValue"||f.name==="QuotedValue")){const E=f.from+1,T=f.to-(o.sliceString(f.to-1,f.to)===(f.name==="BracedValue"?"}":'"')?1:0);m=E,v=T}else if(f)m=f.from,v=f.to;else{const E=t.matchBefore(/[A-Za-z0-9_:.\-/]*/);m=E?E.from:t.pos}const b=bs(t.state),S=[],M=new Set,R=(E,T,D=1)=>{!E||M.has(E)||(M.add(E),S.push({label:E,type:T,apply:E,boost:D}))},A=Vs[s];if(A)for(const E of b[A])R(E,"text",2);if(!c){const E=b.byField.get(s);if(E)for(const T of E)R(T,"text",1.5)}if(s==="month")for(const E of $s)R(E,"constant",1);if(s==="journal"||s==="journaltitle"||s==="shortjournal")for(const E of _s)R(E,"constant",.5);if(s==="crossref"||s==="xref")for(const E of b.keys)R(E,"constant",1);return S.length===0?null:{from:m,to:v,options:S,validFor:/^[^"{}\n]*$/}}function Zs(t){const o=Vt(t.state).resolveInner(t.pos,-1),s=js(o,Ks);if(s&&bt(s,"Field"))return Xs(t,o);if(bt(o,"Entry")){const f=t.state.sliceDoc(Math.max(0,t.pos-1),t.pos);return t.matchBefore(/@[a-zA-Z]*$/)?yr(t):o.name==="EntryKey"||o.name==="EntryType"||!t.explicit&&!/[a-zA-Z_,{\s]/.test(f)?null:Us(t,o)}return yr(t)}function Ys(t){return{syntaxError:()=>t("bibtex.diagnostics.syntaxError"),duplicatePerson:(n,o)=>t("bibtex.diagnostics.duplicatePerson",{field:n,person:o}),unknownEntryType:n=>t("bibtex.diagnostics.unknownEntryType",{entryType:n}),duplicateEntryKey:n=>t("bibtex.diagnostics.duplicateEntryKey",{key:n}),duplicateField:n=>t("bibtex.diagnostics.duplicateField",{field:n}),unknownField:n=>t("bibtex.diagnostics.unknownField",{field:n}),invalidFieldValue:n=>t("bibtex.diagnostics.invalidFieldValue",{field:n}),emptyFieldValue:n=>t("bibtex.diagnostics.emptyFieldValue",{field:n}),verifyInheritedFields:(n,o)=>t("bibtex.diagnostics.verifyInheritedFields",{field:n,fields:o}),missingRequiredFields:n=>t("bibtex.diagnostics.missingRequiredFields",{fields:n}),missingRecommendedFields:n=>t("bibtex.diagnostics.missingRecommendedFields",{fields:n}),entryDescription:n=>t("bibtex.hover.entryDescription",{entryType:`@${n}`}),fieldDescription:n=>t("bibtex.hover.fieldDescription",{field:n}),requiredFields:n=>t("bibtex.hover.requiredFields",{fields:n}),optionalFields:n=>t("bibtex.hover.optionalFields",{fields:n}),exampleLabel:()=>t("bibtex.hover.example"),noteLabel:()=>t("bibtex.hover.note"),authorsNote:()=>t("bibtex.hover.authorsNote"),pagesNote:()=>t("bibtex.hover.pagesNote"),monthNote:()=>t("bibtex.hover.monthNote")}}const Js=gs,Gs=Wr({brackets:"()[]{}"});function hi(t=En){return[Gs,zo(Ss({messages:t})),di(t)]}hi();const el=new Set(["(",")","[","]","{","}"]),tl=/^\d[\w.]*(?=%)/,br=/^\\begin\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/;function nl(t){const n=t.match(br,!1);return!n||typeof n=="boolean"||!zt(n[1])?null:(t.match(br),n[1])}function rl(t,n){const o=qt(t.string,t.pos,n);return o?o.from>t.pos?(t.pos=o.from,"string"):(t.pos=o.to,"tag"):(t.skipToEnd(),"string")}function il(t){const n=t.match(tl);return!!(n&&typeof n!="boolean")}function ol(t){const n=Ue.copyState?.(t)??t;if(!n||typeof n!="object")return n;const o=n;return Array.isArray(o.cmdState)?{...o,cmdState:o.cmdState.map(s=>!s||typeof s!="object"?s:Object.assign(Object.create(Object.getPrototypeOf(s)),s))}:n}const al={name:Ue.name,startState(t){return{stexState:Ue.startState?.(t)??{},literalEnvironment:null}},copyState(t){return{stexState:ol(t.stexState),literalEnvironment:t.literalEnvironment}},blankLine(t,n){t.literalEnvironment||Ue.blankLine?.(t.stexState,n)},indent(t,n,o){return t.literalEnvironment?null:Ue.indent?.(t.stexState,n,o)??null},languageData:Ue.languageData,tokenTable:Ue.tokenTable,mergeTokens:Ue.mergeTokens,token(t,n){if(n.literalEnvironment){const v=rl(t,n.literalEnvironment);return v==="tag"&&(n.literalEnvironment=null),v}const o=nl(t);if(o)return n.literalEnvironment=o,"tag";const s=jt(t.string,t.pos);if(s!==null)return t.pos=s,"string";if(il(t))return"atom";const c=t.pos,f=Ue.token(t,n.stexState),m=t.string.slice(c,t.pos);return el.has(m)?"bracket":f}},sl=Ho.define(al),ll=new Set(["math","displaymath","equation","align","alignat","flalign","gather","multline","split","aligned","alignedat","gathered","matrix","pmatrix","bmatrix","vmatrix","cases","dcases","rcases","smallmatrix","subarray","array"]);function Me(t,n){let o=0;for(let s=n-1;s>=0&&t[s]==="\\";s-=1)o+=1;return o%2===1}function Ot(t,n){const o=t.indexOf(`
|
|
113
|
-
`,n);return o<0?t.length:o+1}function pi(t){return t.replace(/\*$/,"").toLowerCase()}function mi(t,n){if(t[n]!=="\\"||Me(t,n))return null;const o=/^\\(begin|end)[ \t]*\{[ \t]*([^{}\s]+)[ \t]*\}/.exec(t.slice(n));return o?{type:o[1],name:o[2],end:n+o[0].length}:null}function gi(t,n){return t[n]!=="\\"||Me(t,n)?null:jt(t,n)}function kr(t,n,o,s=!1){for(let c=n;c<t.length;c+=1){if(s&&(t[c]===`
|
|
114
|
-
`&&/^[\t \r]*\n/.test(t.slice(c+1))||t[c]==="\\"&&!Me(t,c)&&/^\\par(?![A-Za-z@])/.test(t.slice(c))))return-1;if(t[c]==="%"&&!Me(t,c)){c=Ot(t,c)-1;continue}if(o==="dollar"&&t[c]==="$"&&!Me(t,c)||o==="paren"&&t[c]==="\\"&&t[c+1]===")"&&!Me(t,c)||o==="bracket"&&t[c]==="\\"&&t[c+1]==="]"&&!Me(t,c))return c}return-1}function cl(t,n){for(let o=n;o<t.length-1;o+=1){if(t[o]==="%"&&!Me(t,o)){o=Ot(t,o)-1;continue}if(t[o]==="$"&&t[o+1]==="$"&&!Me(t,o))return o}return-1}function ul(t,n,o){let s=1;for(let c=n;c<t.length;c+=1){if(t[c]==="%"&&!Me(t,c)){c=Ot(t,c)-1;continue}const f=gi(t,c);if(f!==null){c=f-1;continue}const m=mi(t,c);if(!(!m||m.name!==o)){if(m.type==="begin")s+=1;else if(--s===0)return{from:c,to:m.end};c=m.end-1}}return null}function sn(t,n,o){return n>=t.from&&(n<t.to||n===t.to&&o<0)}function vn(t){let n="";for(let o=0;o<t.length;o+=1){if(t[o]==="%"&&!Me(t,o)){const s=Ot(t,o);s>o&&t[s-1]===`
|
|
115
|
-
`&&(n+=`
|
|
116
|
-
`),o=s-1;continue}n+=t[o]}return n.replace(/\\(?:label|notag|nonumber)\b(?:[ \t]*\{[^{}]*\})?/g,"")}function fl(t,n,o,s){let c=vn(t.slice(o,s));const f=pi(n);return f==="equation"||f==="displaymath"?c:f==="align"||f==="flalign"?`\\begin{aligned}${c}\\end{aligned}`:f==="alignat"?(c=c.replace(/^\s*\{[^{}]*\}/,""),`\\begin{aligned}${c}\\end{aligned}`):f==="gather"||f==="multline"?`\\begin{gathered}${c}\\end{gathered}`:vn(t)}function Cr(t,n,o,s){return{from:t,to:n,source:vn(o),displayMode:s}}function Or(t){return/\.(?:tex|ltx|sty|cls)$/i.test(t)}function dl(t,n,o=1){const s=Math.max(0,Math.min(t.length,n));for(let c=0;c<t.length&&c<=s;c+=1){if(t[c]==="%"&&!Me(t,c)){c=Ot(t,c)-1;continue}const f=gi(t,c);if(f!==null){c=f-1;continue}const m=mi(t,c);if(m?.type==="begin"){const R=pi(m.name),A=zt(m.name),E=ll.has(R);if(!A&&!E)continue;const T=A?qt(t,m.end,m.name):ul(t,m.end,m.name);if(A){T?c=T.to-1:c=t.length;continue}if(E&&T){const D={from:c,to:T.to,source:fl(t.slice(c,T.to),m.name,m.end-c,T.from-c),displayMode:!0};if(sn(D,s,o))return D;c=T.to-1;continue}}if(t[c]==="\\"&&!Me(t,c)&&(t[c+1]==="("||t[c+1]==="[")){const R=t[c+1]==="[",A=kr(t,c+2,R?"bracket":"paren");if(A>=0){const E=Cr(c,A+2,t.slice(c+2,A),R);if(sn(E,s,o))return E;c=E.to-1;continue}}if(t[c]!=="$"||Me(t,c))continue;const v=t[c+1]==="$",b=v?2:1,S=v?cl(t,c+2):kr(t,c+1,"dollar",!0);if(S<0)continue;if(!v&&t[S+1]==="$"){c=S;continue}const M=Cr(c,S+b,t.slice(c+b,S),v);if(sn(M,s,o))return M;c=M.to-1}return null}let It=null;function hl(){return It||(It=Promise.all([dr(()=>import("./katex-COYOr4nK.js"),[],import.meta.url),dr(()=>Promise.resolve({}),__vite__mapDeps([0]),import.meta.url)]).then(([t])=>t.default).catch(t=>{throw It=null,t})),It}function pl(t,n,o,s,c){let f=!1;return{pos:n,end:o,above:!0,arrow:!0,create(){const m=document.createElement("div");return m.className=`texlite-math-hover${s?" display":" inline"}`,m.setAttribute("role","status"),m.setAttribute("aria-label",c.preview),m.textContent=c.loading,hl().then(v=>{if(!f){m.replaceChildren();try{v.render(t,m,{displayMode:s,throwOnError:!0,strict:"ignore",trust:!1})}catch{m.textContent=c.unavailable,m.classList.add("texlite-math-hover-error")}}}).catch(()=>{f||(m.textContent=c.unavailable,m.classList.add("texlite-math-hover-error"))}),{dom:m,destroy(){f=!0}}}}}function xr(t){return Hr((n,o,s)=>{const c=dl(n.state.doc.toString(),o,s);return!c||!c.source.trim()||c.source.length>32*1024?null:pl(c.source,c.from,c.to,c.displayMode,t)},{hoverTime:350,hideOnChange:!0})}const ml=/^\\(begin|end)\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/,gl=/\\begin\s*\{\s*[A-Za-z0-9@:_*.\-]*\s*\}?$/,Sr=/^\s*\\(part|chapter|section|subsection|subsubsection)(?![A-Za-z@])\*?/,wr={part:0,chapter:0,section:1,subsection:2,subsubsection:3};function yn(t,n){let o=0;for(let s=n-1;s>=0&&t[s]==="\\";s-=1)o+=1;return o%2===1}function Mr(t){for(let n=0;n<t.length;n+=1)if(t[n]==="%"&&!yn(t,n))return n;return t.length}function kt(t,n=0,o={name:null}){const s=t.length,c=[];let f=n;for(;f<s;){if(o.name){const S=qt(t,f,o.name);if(!S)break;c.push({kind:"end",name:o.name,from:S.from,to:S.to}),o.name=null,f=S.to;continue}if(t[f]==="%"&&!yn(t,f))break;if(t[f]!=="\\"||yn(t,f)){f+=1;continue}const m=jt(t,f,s);if(m!==null){f=m;continue}const v=ml.exec(t.slice(f,s));if(!v){f+=1;continue}const b=f+v[0].length;c.push({kind:v[1],name:v[2],from:f,to:b}),v[1]==="begin"&&zt(v[2])&&(o.name=v[2]),f=b}return c}function vi(t,n,o){let s=t.lineAt(Math.min(n,t.length)),c=Math.max(0,n-s.from),f=1;const m={name:zt(o)?o:null};for(let v=s.number;v<=t.lines;v+=1){s=t.line(v);const b=kt(s.text,c,m);c=0;for(const S of b)if(S.name===o){if(S.kind==="begin"){f+=1;continue}if(f-=1,f===0)return{from:s.from+S.from,to:s.from+S.to}}}return null}function yi(t,n){const o=t.lineAt(Math.min(n,t.length)),s=o.text.slice(0,Math.max(0,n-o.from)),c=gl.exec(s);return c?o.from+c.index:null}function vl(t,n,o,s){const c=[],f={name:null};for(let m=1;m<=t.lines;m+=1){const v=t.line(m),b=kt(v.text,0,f);for(const S of b){const M=v.from+S.from;if(M>=o)return c.at(-1)?.name===s&&(c.at(-1)?.from??n)<n;M===n&&S.kind==="begin"||(S.kind==="begin"?c.push({name:S.name,from:M}):c.at(-1)?.name===S.name&&c.pop())}}return!1}function bi(t,n,o,s){const c=vi(t,o,s);return!c||vl(t,n,c.from,s)?null:c}function yl(t,n){const o=t.doc.lineAt(n),s=Sr.exec(o.text.slice(0,Mr(o.text)));if(!s)return null;const c=wr[s[1]],f={name:null};kt(o.text,0,f);for(let m=o.number+1;m<=t.doc.lines;m+=1){const v=t.doc.line(m),b=f.name!==null;if(kt(v.text,0,f),b||f.name)continue;const S=Sr.exec(v.text.slice(0,Mr(v.text)));if(S&&wr[S[1]]<=c)return{from:o.to,to:Math.max(o.to,v.from-1)}}return o.to<t.doc.length?{from:o.to,to:t.doc.length}:null}function bl(t,n){const o=t.doc.lineAt(n),s=kt(o.text).find(c=>c.kind==="begin");if(s){const c=vi(t.doc,o.from+s.to,s.name);if(c&&c.from>o.to)return{from:o.to,to:c.from}}return yl(t,n)}const kl=Wo.of((t,n)=>bl(t,n));function ki(t,n,o){const s=t.slice(0,n)+o+t.slice(n),c=n+o.length,f=s.lastIndexOf(`
|
|
117
|
-
`,Math.max(0,c-1))+1,m=s.indexOf(`
|
|
118
|
-
`,c);return{nextSource:s,cursor:c,prefix:s.slice(f,c),suffix:s.slice(c,m<0?s.length:m)}}function Ci(t){return t.suffix.trim()?null:t.prefix.match(/^([ \t]*)\\begin\s*\{\s*([A-Za-z][A-Za-z0-9*:_-]*)\s*\}\s*$/)}function Oi(t,n){const o=n[2],s=Uo.of(t.nextSource.split(`
|
|
119
|
-
`)),c=yi(s,t.cursor);if(c!==null&&bi(s,c,t.cursor,o))return null;const f=n[1]+" ";return{insert:`
|
|
120
|
-
`+f+`
|
|
121
|
-
`+n[1]+"\\end{"+o+"}",cursorOffset:1+f.length,kind:"environment"}}function xi(t){return t.suffix.trim()?null:t.prefix.match(/^(.*\\left\s*)(\\[{}]|[()[\]|.])\s*$/)}function Si(t){const o={"(":"\\right)",")":"\\right(","[":"\\right]","]":"\\right[","|":"\\right|","\\{":"\\right\\}","\\}":"\\right\\{"}[t[2]];return o?{insert:o,cursorOffset:0,kind:"delimiter"}:null}function Cl(t,n,o,s){if(n!==o||!s)return null;const c=ki(t,n,s),f=Ci(c),m=f?null:xi(c);return!f&&!m||wn(c.nextSource,c.cursor)?null:f?Oi(c,f):m?Si(m):null}function Ol(t,n){if(n<0||n>t.length)return null;const o=ki(t,n,""),s=Ci(o),c=s?null:xi(o);return!s&&!c||wn(o.nextSource,o.cursor)?null:s?Oi(o,s):c?Si(c):null}function xl(t,n,o,s,c){if(t.state.readOnly||t.composing||t.state.selection.ranges.length!==1)return!1;const f=Cl(t.state.doc.toString(),n,o,s);if(!f)return!1;const m=c();if(!m.docChanged)return!1;const v=m.newSelection.main.head;return t.dispatch(t.state.update(m,{sequential:!0,changes:{from:v,insert:f.insert},selection:{anchor:v+f.cursorOffset},annotations:Ur.userEvent.of("input.type")})),!0}const Sl=Dt.transactionFilter.of(t=>{if(t.docChanged||!t.selection||!t.isUserEvent("input")||t.startState.readOnly||t.newSelection.ranges.length!==1||!t.newSelection.main.empty)return t;const n=t.newSelection.main.head,o=Ol(t.newDoc.toString(),n);return o?[t,{sequential:!0,changes:{from:n,insert:o.insert},selection:{anchor:n+o.cursorOffset},userEvent:"input.complete"}]:t}),wl=new Set(ka);function Ml(t){return/[A-Za-z@0-9:_-]/.test(t)}function El(t,n){let o=0;for(let s=n-1;s>=0&&t[s]==="\\";s-=1)o+=1;return o%2===1}function xt(t,n){return t[n]==="%"&&!El(t,n)}function St(t,n){const o=t.indexOf(`
|
|
122
|
-
`,n);return o===-1?t.length:o}function it(t,n){let o=n;for(;o<t.length;){if(/\s/.test(t[o])){o+=1;continue}if(xt(t,o)){o=St(t,o);continue}break}return o}function ft(t,n,o,s){if(t[n]!==o)return null;let c=0,f=0;for(let m=n;m<t.length;m+=1){const v=t[m];if(v==="\\"&&m+1<t.length){m+=1;continue}if(xt(t,m)){m=St(t,m)-1;continue}if(o==="["){if(v==="{"){f+=1;continue}if(v==="}"&&f>0){f-=1;continue}if(f>0)continue}if(v===o){c+=1;continue}if(v===s&&(c-=1,c===0))return{from:n,to:m+1,contentFrom:n+1,contentTo:m}}return null}function $t(t,n,o){const s=[];let c=n;for(;s.length<o;){for(c=it(t,c);t[c]==="[";){const m=ft(t,c,"[","]");if(!m)return s;c=it(t,m.to)}if(t[c]!=="{")break;const f=ft(t,c,"{","}");if(!f)break;s.push(f),c=f.to}return s}function Ll(t,n,o){const s=[];let c=n;for(;s.length<o&&(c=it(t,c),t[c]==="[");){const f=ft(t,c,"[","]");if(!f)break;s.push(f),c=f.to}return s}function Tl(t,n){if(t[n]!=="\\"||n+1>=t.length)return null;let o=n+1;if(!/[A-Za-z@]/.test(t[o]))return{name:t[o],from:n,to:o+1};for(;o<t.length&&Ml(t[o]);)o+=1;const s=t.slice(n+1,o);return t[o]==="*"&&(o+=1),{name:s,from:n,to:o}}function Rl(t,n){if(n.name!=="begin")return n.to;const o=$t(t,n.to,1)[0];if(!o)return n.to;const s=t.slice(o.contentFrom,o.contentTo).trim();return wl.has(s)?qt(t,o.to,s)?.to??t.length:n.to}function Rn(t,n){let o=0;for(;o<t.length;){if(xt(t,o)){o=St(t,o);continue}if(t[o]!=="\\"){o+=1;continue}const s=Tl(t,o);if(!s){o+=1;continue}const c=jt(t,s.from);if(c!==null&&c>s.to){o=c;continue}const f=Rl(t,s);if(f>s.to){o=f;continue}n(s),o=s.to}}function Al(t,n){const o=t[n],s=o==="{"?"}":")";if(o!=="{"&&o!=="(")return null;let c=0,f=0,m=!1;for(let v=n;v<t.length;v+=1){const b=t[v];if(b==="\\"&&v+1<t.length){v+=1;continue}if(o==="{"){if(b==="{"){c+=1;continue}if(b!=="}")continue;if(c-=1,c===0)return{from:n,to:v+1,contentFrom:n+1,contentTo:v};continue}if(m){b==='"'&&(m=!1);continue}if(f>0){b==="{"?f+=1:b==="}"&&(f-=1);continue}if(b==="{"){f=1;continue}if(b==='"'){m=!0;continue}if(b==="("){c+=1;continue}if(b===s&&(c-=1,c===0))return{from:n,to:v+1,contentFrom:n+1,contentTo:v}}return null}function Pl(t,n){let o=n.contentFrom;for(;o<n.contentTo&&/\s/.test(t[o]);)o+=1;if(o>=n.contentTo)return null;let s=o;for(;s<n.contentTo&&t[s]!==","&&!/\s/.test(t[s]);)s+=1;let c=s;for(;c>o&&/\s/.test(t[c-1]);)c-=1;if(c<=o)return null;const f=it(t,s);return f<n.contentTo&&t[f]!==","?null:{key:t.slice(o,c),from:o,to:c}}function Nl(t){const n=[];let o=0;for(;o<t.length;){if(xt(t,o)){o=St(t,o);continue}if(t[o]!=="@"){o+=1;continue}let s=o+1;for(;s<t.length&&/[A-Za-z]/.test(t[s]);)s+=1;if(s===o+1){o+=1;continue}let c=s;for(;c<t.length&&/\s/.test(t[c]);)c+=1;const f=Al(t,c);if(!f){o=s;continue}const m=t.slice(o+1,s).toLowerCase();if(m!=="string"&&m!=="preamble"&&m!=="comment"){const v=Pl(t,f);v&&n.push({...v,entryFrom:o,entryTo:f.to})}o=f.to}return n}const Bl={kind:"citation",argumentKind:"mandatory",maximumArguments:1},Fl={kind:"citation",argumentKind:"mandatory",maximumArguments:Number.MAX_SAFE_INTEGER},Il={kind:"label",argumentKind:"mandatory",maximumArguments:1},Dl={kind:"label",argumentKind:"mandatory",maximumArguments:2},$l={kind:"label",argumentKind:"optional",maximumArguments:1},Er={href:null,hyperref:$l,crefrange:Dl,citestyle:null,setcitestyle:null,newcites:null,citetext:null,declarecitecommand:null,declaremulticitecommand:null,declareautocitecommand:null,declarecitewrappercommand:null,declarecitepunctuation:null,declarecitedelimiter:null,declarecitedriver:null,declarecitealias:null,ateverycite:null,ateverycitekey:null,atnextcite:null,atnextcitekey:null};function wi(t){const n=t.toLowerCase();return Object.prototype.hasOwnProperty.call(Er,n)?Er[n]??null:n==="nocite"||n.includes("cite")?n.endsWith("cites")?Fl:Bl:n==="ref"||n.endsWith("ref")?Il:null}function bn(t,n){const o=[],s=Zr(t.slice(n.contentFrom,n.contentTo));let c=0;for(let f=0;f<=s.length;f+=1){if(f!==s.length&&s[f]!==",")continue;let m=c,v=f;for(;m<v&&/\s/.test(s[m]);)m+=1;for(;v>m&&/\s/.test(s[v-1]);)v-=1;if(v>m){const b=n.contentFrom+m,S=n.contentFrom+v;o.push({key:t.slice(b,S),from:b,to:S})}c=f+1}return o}function _l(t,n,o){let s=n;for(let c=0;c<o.maximumArguments;c+=1){if(s=it(t,s),o.argumentKind==="optional"){if(t[s]!=="[")return null;const m=ft(t,s,"[","]");if(!m)return s+1;s=m.to;continue}for(;t[s]==="[";){const m=ft(t,s,"[","]");if(!m)return null;s=it(t,m.to)}if(t[s]!=="{")return null;const f=ft(t,s,"{","}");if(!f)return s+1;s=f.to}return null}function Ql(t,n){let o=n;for(let c=n;c<t.length;c+=1){if(xt(t,c)){c=St(t,c)-1;continue}t[c]===","&&(o=c+1)}const s=it(t,o);return{from:s,query:t.slice(s)}}function Mi(t,n){let o=null;return Rn(t,s=>{const c=wi(s.name);if(!c||c.kind!==n)return;const f=_l(t,s.to,c);f!==null&&(o=f)}),o===null?null:Ql(t,o)}function Kl(t){return Mi(t,"citation")}function Vl(t){return Mi(t,"label")}function jl(t){const n=[];return Rn(t,o=>{const s=wi(o.name);if(!s)return;const c=s.argumentKind==="optional"?Ll(t,o.to,s.maximumArguments):$t(t,o.to,s.maximumArguments);for(const f of c)for(const m of bn(t,f))n.push({kind:s.kind,command:o.name,...m})}),n.sort((o,s)=>o.from-s.from||o.to-s.to)}function ql(t,n){const o=[];return Rn(t,s=>{if(n==="label"&&(s.name==="label"||s.name==="hypertarget")){const c=$t(t,s.to,1)[0];if(!c)return;for(const f of bn(t,c))o.push({key:f.key,command:s.name,targetFrom:s.from,targetTo:c.to,source:"label"});return}if(n==="citation"&&s.name==="bibitem"){const c=$t(t,s.to,1)[0];if(!c)return;for(const f of bn(t,c))o.push({key:f.key,command:s.name,targetFrom:s.from,targetTo:c.to,source:"bibitem"})}}),o}function zl(t){return Nl(t).map(n=>({key:n.key,command:"bibtex",targetFrom:n.entryFrom,targetTo:n.entryTo,source:"bibtex"}))}function Lr(t,n,o=!1){return o?n==="citation"?zl(t):[]:ql(t,n)}const Tr=new WeakMap;function wt(t){let n=Tr.get(t);return n===void 0&&(n=t.state.sliceDoc(0,t.pos),Tr.set(t,n)),n}function Hl(t){return wt(t)}function ln(t,n,o=!1){const c=wt(t).match(n);if(!c||c.index===void 0)return null;const f={from:t.pos-c[1].length,query:c[1]};return o?Zl(f):f}function Wl(t){const o=wt(t).match(/\\(begin|end)\s*\{([^{}]*)$/);return!o||o.index===void 0?null:{from:t.pos-o[2].length,query:o[2],command:o[1]}}function Ul(t){return Kl(wt(t))}function Xl(t){return Vl(wt(t))}function Zl(t){const n=t.query.lastIndexOf(","),o=t.query.slice(n+1),s=o.match(/^\s*/)?.[0].length??0;return{from:t.from+n+1+s,query:o.slice(s)}}function Yl(t,n,o,s,c="begin"){const f=t.sliceString(o,o+1)==="}"?1:0,m=`${s}}`,v=yi(t,n),b=v===null?null:bi(t,v,o+f,s);if(c==="end"||b)return{to:o+f,insert:m,cursor:n+m.length,reusesExistingEnd:!0};const M=t.lineAt(n).text.match(/^\s*/)?.[0]??"";return{to:o+f,insert:`${m}
|
|
123
|
-
${M}
|
|
124
|
-
${M}\\end{${s}}`,cursor:n+m.length+1+M.length+1,reusesExistingEnd:!1}}function Jl(t,n){let o=n;for(;/[ \t\r\n]/.test(t[o]??"");)o+=1;return o}function kn(t,n,o="{",s="}"){const c=Jl(t,n);if(t[c]!==o)return null;let f=1;for(let m=c+1;m<t.length;m+=1){if(t[m]==="\\"){m+=1;continue}if(t[m]===o)f+=1;else if(t[m]===s&&--f===0)return{from:c,to:m+1,content:t.slice(c+1,m)}}return null}function cn(t,n){if(n.length!==0)return t+n.map((o,s)=>{const c=`\${${s+1}}`;return o.optional?`[${c}]`:`{${c}}`}).join("")}function Rr(t,n){return!Number.isFinite(t)||t<=0?[]:n?[{optional:!0},...Array.from({length:Math.max(0,t-1)},()=>({optional:!1}))]:Array.from({length:t},()=>({optional:!1}))}function Gl(t){const n=[];for(let o=0;o<t.length;){const s=t[o];if(/[ \t\r\n+\-!]/.test(s)){o+=1;continue}if(s==="m"){n.push({optional:!1}),o+=1;continue}if(s==="o"){n.push({optional:!0}),o+=1;continue}if(s==="O"){const c=kn(t,o+1);if(!c)return null;n.push({optional:!0}),o=c.to;continue}return null}return n}const ec=/\\(?:NewDocumentCommand|RenewDocumentCommand|ProvideDocumentCommand|DeclareDocumentCommand|DeclareExpandableDocumentCommand|RenewExpandableDocumentCommand|ProvideExpandableDocumentCommand)\b/g;function tc(t){const n=[];for(const o of t.matchAll(ec)){const s=kn(t,o.index+o[0].length);if(!s)continue;const c=/^\s*\\([A-Za-z@][A-Za-z@0-9:_]*)\s*$/.exec(s.content)?.[1];if(!c)continue;const f=kn(t,s.to);f&&n.push({name:c,specification:f.content})}return n}const nc=["\\noindent","\\indent","\\par","\\leavevmode","\\newline","\\linebreak","\\nolinebreak","\\pagebreak","\\nopagebreak","\\newpage","\\clearpage","\\cleardoublepage","\\smallskip","\\medskip","\\bigskip","\\smallbreak","\\medbreak","\\bigbreak","\\hfill","\\hfil","\\vfill","\\vfil","\\thinspace","\\negthinspace","\\quad","\\qquad","\\enspace","\\enskip","\\,","\\:","\\;","\\!","\\centering","\\raggedright","\\raggedleft","\\raggedbottom","\\flushbottom","\\maketitle","\\tableofcontents","\\listoffigures","\\listoftables","\\appendix","\\bfseries","\\mdseries","\\rmfamily","\\sffamily","\\ttfamily","\\upshape","\\itshape","\\slshape","\\scshape","\\normalfont","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge","\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle","\\limits","\\nolimits","\\sum","\\prod","\\coprod","\\int","\\iint","\\iiint","\\oint","\\bigcap","\\bigcup","\\bigvee","\\bigwedge","\\lim","\\limsup","\\liminf","\\sin","\\cos","\\tan","\\cot","\\log","\\ln","\\exp","\\max","\\min","\\sup","\\inf","\\det","\\dim","\\gcd","\\ker","\\Pr","\\ldots","\\cdots","\\vdots","\\ddots","\\dotsb","\\dotsc","\\dotsm","\\dotso","\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\varepsilon","\\theta","\\vartheta","\\lambda","\\mu","\\pi","\\varpi","\\rho","\\sigma","\\tau","\\phi","\\varphi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\pm","\\mp","\\times","\\div","\\cdot","\\leq","\\geq","\\neq","\\approx","\\equiv","\\sim","\\simeq","\\propto","\\in","\\notin","\\subset","\\subseteq","\\supset","\\supseteq","\\cup","\\cap","\\emptyset","\\varnothing","\\forall","\\exists","\\nexists","\\infty","\\partial","\\nabla","\\angle","\\parallel","\\perp","\\mid","\\LaTeX","\\TeX","\\today","\\protect","\\nocite","\\footnotemark","\\hrule","\\verb","\\verb*"];function rc(){return[...nc.map(t=>({label:t,type:"keyword"})),oe("\\section{${title}}",{label:"\\section"}),oe("\\subsection{${title}}",{label:"\\subsection"}),oe("\\textbf{${text}}",{label:"\\textbf"}),oe("\\emph{${text}}",{label:"\\emph"}),oe("\\cite{${key}}",{label:"\\cite"}),oe("\\ref{${label}}",{label:"\\ref"}),oe("\\label{${label}}",{label:"\\label"}),oe("\\includegraphics[width=${0.8}\\textwidth]{${file}}",{label:"\\includegraphics"}),oe(`\\begin{itemize}
|
|
125
|
-
\\item \${item}
|
|
126
|
-
\\end{itemize}`,{label:"\\begin{itemize}"}),oe(`\\begin{enumerate}
|
|
127
|
-
\\item \${item}
|
|
128
|
-
\\end{enumerate}`,{label:"\\begin{enumerate}"}),oe(`\\begin{equation}
|
|
129
|
-
\${equation}
|
|
130
|
-
\\end{equation}`,{label:"\\begin{equation}"}),oe(`\\begin{figure}[htbp]
|
|
131
|
-
\\centering
|
|
132
|
-
\${content}
|
|
133
|
-
\\caption{\${caption}}
|
|
134
|
-
\\label{fig:\${label}}
|
|
135
|
-
\\end{figure}`,{label:"\\begin{figure}"})]}function ic(t){const n=[],o=[],s=[],c=[],f=[],m=[],v=Zr(Ca(t)),b=(S,M,R,A,E)=>{M&&!S.some(T=>T.label===M)&&S.push({label:M,detail:R,kind:A,source:"Current file",...E?{apply:E}:{}})};for(const S of v.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?(?:\s*(\[[^\]]*\]))?/g)){const M=Rr(Number.parseInt(S[2]??"0",10),!!S[3]);b(n,`\\${S[1]}`,"Project command","function",cn(`\\${S[1]}`,M))}for(const S of tc(v)){const M=Gl(S.specification);b(n,`\\${S.name}`,"Project command","function",M?cn(`\\${S.name}`,M):void 0)}for(const S of v.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const M=[...(S[2]??"").matchAll(/#\d+/g)].length;b(n,`\\${S[1]}`,"Project macro","function",cn(`\\${S[1]}`,Rr(M,!1)))}for(const S of v.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))b(n,`\\${S[1]}`,"Project math delimiter","function");for(const S of v.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))b(n,`\\${S[1]}`,"Expl3 project command","function");for(const S of v.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))b(o,S[1].trim(),"Project environment","keyword");for(const S of Lr(t,"label"))S.source==="label"&&b(s,S.key,"Label","constant");for(const S of v.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^\]]*\])?\s*\{([^}]+)\}/g))for(const M of S[1].split(","))b(f,M.trim(),"Package","text");for(const S of v.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))b(m,(S[1]??S[2]??"").trim(),"Project file","text");for(const S of Lr(t,"citation"))S.source==="bibitem"&&b(c,S.key,"Bibliography key","constant");return{commands:n,environments:o,labels:s,citations:c,packages:f,classes:[],files:m}}function oc(t){return(t?.citations??[]).filter(n=>/\.bib$/i.test(n.source??""))}const Ar=new WeakMap;function ac(t){const n=t.state.doc,o=Ar.get(n);if(o)return o;const s=ic(t.state.doc.toString());return Ar.set(n,s),s}const Pr={"Project command":"projectCommand","Project macro":"projectMacro","Expl3 project command":"expl3Command","Project math operator":"mathOperator","Project math delimiter":"mathDelimiter","Project environment":"projectEnvironment","Project file":"projectFile",Package:"package","Document class":"documentClass","Current file":"currentFile",Project:"project",LaTeX:"latex"};function sc(t,n,o=!0){const s=Pr[t.detail],c=t.source?Pr[t.source]:void 0,f=t.detail.match(/^Project command \((\d+) arguments?\)$/),m=t.source==="LaTeX"?"":f?n("completions.projectCommandArgs",{count:Number(f[1])}):s?n(`completions.${s}`):t.source==="LaTeX"?n("completions.standard"):t.detail,v=t.source==="LaTeX"?"":c?n(`completions.${c}`):t.source,b=v&&m?`${m} · ${v}`:m||v||void 0,S={label:t.label,type:t.kind,...b?{detail:b}:{},...t.info?{info:t.info}:{}};return o&&t.apply?oe(t.apply,S):S}function rt(t,...n){const o=[],s=new Set;for(const c of n)for(const f of c){const m="kind"in f?sc(f,t):f;s.has(m.label)||(s.add(m.label),o.push(m))}return o}function Nr(t){return t.map(({detail:n,...o})=>o)}function Br(t){return t.map(({apply:n,...o})=>o)}function lc(t,n){return{...t,apply(o,s,c,f){const m=s.label,v=Yl(o.state.doc,c,f,m,n);o.dispatch({changes:{from:c,to:v.to,insert:v.insert},selection:{anchor:v.cursor},annotations:[Xo.of(s),Ur.userEvent.of("input.complete")]})}}}function cc(t,n,o){const s=()=>ac(t),c=()=>wn(Hl(t),t.pos)!==null,f=Wl(t);if(f){if(c())return null;const A=rt(n,Br(s().environments),Br(o?.environments??[]));return{from:f.from,options:Nr(A.map(E=>lc(E,f.command))),validFor:/^[A-Za-z0-9*:_-]*$/}}const m=Xl(t);if(m&&c())return null;if(m)return{from:m.from,options:rt(n,s().labels,o?.labels??[]),validFor:/^[^,{}\s]*$/};const v=Ul(t);if(v&&c())return null;if(v)return{from:v.from,options:rt(n,s().citations,oc(o)),validFor:/^[^,{}\s]*$/};const b=ln(t,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(b&&c())return null;if(b)return{from:b.from,options:rt(n,s().files,o?.files??[]),validFor:/^[^{}]*$/};const S=ln(t,/\\(?:usepackage|RequirePackage)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/,!0);if(S&&c())return null;if(S)return{from:S.from,options:rt(n,s().packages,o?.packages??[]),validFor:/^[^,{}\s]*$/};const M=ln(t,/\\documentclass(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(M&&c())return null;if(M)return{from:M.from,options:rt(n,o?.classes??[]),validFor:/^[^{}]*$/};const R=t.matchBefore(/\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/);return(R||t.explicit)&&c()?null:R||t.explicit?{from:R?.from??t.pos,options:Nr(rt(n,s().commands,o?.commands??[],rc())),validFor:/^\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/}:null}const Cn=Qt.define(),Fr=Sn.define(),uc={undo:()=>!1,redo:()=>!1},An=Kt.define({combine:t=>t.at(-1)??uc});Fe.defineAction("texliteUndo",t=>{t.cm6.state.facet(An).undo()||t.execCommand("undo")});Fe.defineAction("texliteRedo",t=>{t.cm6.state.facet(An).redo()||t.execCommand("redo")});Fe.mapCommand("u","action","texliteUndo",{},{context:"normal"});Fe.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const fc=_t.define({create:()=>Y.none,update(t,n){let o=t.map(n.changes);for(const s of n.effects)s.is(Cn)&&(o=Cc(s.value,n.state.doc.length));return o},provide:t=>fe.decorations.from(t)}),Ei=Qt.define(),dc=_t.define({create:()=>Y.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=Y.none);for(const s of n.effects)s.is(Ei)&&(o=kc(s.value,n.state.doc.length));return o},provide:t=>fe.decorations.from(t)}),On=Qt.define(),hc=Y.mark({class:"cm-spell-error-active"}),pc=_t.define({create:()=>Y.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=Y.none);for(const s of n.effects){if(!s.is(On))continue;const c=s.value;o=c&&c.to>c.from?Y.set([hc.range(c.from,c.to)]):Y.none}return o},provide:t=>fe.decorations.from(t)}),mc={enabled:!1,title:()=>""},Ct=Kt.define({combine:t=>t.at(-1)??mc}),gc=dt.fromClass(class{constructor(t){this.view=t,this.decorations=Ir(t)}view;decorations;update(t){(t.docChanged||t.viewportChanged||t.startState.facet(Ct)!==t.state.facet(Ct))&&(this.decorations=Ir(this.view))}},{decorations:t=>t.decorations});function Ir(t){const n=t.state.facet(Ct);if(!n.enabled||t.state.doc.length===0)return Y.none;const o=vc(t),s=o.reduce((v,b)=>Math.max(v,b.to),0),c=t.state.sliceDoc(0,s),f=[],m=new Set;for(const v of jl(c)){const b=v.from,S=v.to;if(!o.some(R=>b>=R.from&&S<=R.to))continue;const M=[v.kind,v.key,String(b),String(S)].join(":");m.has(M)||S<=b||(m.add(M),f.push(Y.mark({class:v.kind==="citation"?"cm-latex-citation-key":"cm-latex-label-key",attributes:{title:n.title(v),spellcheck:"false","data-latex-reference-kind":v.kind,"data-latex-reference-key":v.key,"data-latex-reference-from":String(b),"data-latex-reference-to":String(S),"data-latex-reference-command":v.command}}).range(b,S)))}return f.length?Y.set(f,!0):Y.none}function vc(t){const n=t.state.doc,o=1024,s=(t.visibleRanges.length?t.visibleRanges:[{from:0,to:n.length}]).map(f=>{const m=Math.max(0,f.from-o),v=Math.min(n.length,f.to+o),b=n.lineAt(m).from,S=n.lineAt(Math.max(m,Math.max(0,v-1))).to;return{from:b,to:S}}).sort((f,m)=>f.from-m.from),c=[];for(const f of s){const m=c.at(-1);m&&f.from<=m.to?m.to=Math.max(m.to,f.to):c.push(f)}return c}function Dr(t){if(!(t instanceof HTMLElement))return null;const n=t.closest("[data-latex-reference-kind][data-latex-reference-key]"),o=n?.dataset.latexReferenceKind,s=n?.dataset.latexReferenceKey;return o!=="citation"&&o!=="label"||!s?null:{kind:o,key:s,from:Number(n.dataset.latexReferenceFrom)||0,to:Number(n.dataset.latexReferenceTo)||0,command:n.dataset.latexReferenceCommand??""}}function Ac({value:t,filePath:n,readOnly:o,comments:s,focusComment:c,preferences:f,completionIndex:m,jumpTo:v,searchRequest:b,nativeSpellCheck:S,spellCheckIssues:M,spellCheckJump:R,collaboration:A,onChange:E,onSelection:T,onCommentClick:D,onSpellCheckReplace:z,onReferenceNavigate:W,onCursor:ie}){const{t:Q,i18n:de}=ko(),he=Z.useRef(null),J=Z.useRef(null),ce=Z.useRef(E),Ie=Z.useRef(T),ot=Z.useRef(D),Te=Z.useRef(z),qe=Z.useRef(W),Ye=Z.useRef(ie),be=Z.useRef(M),Mt=Z.useRef(b),ht=Z.useRef(m),Et=Z.useRef(new Nt),ze=Z.useRef(new Nt),P=Z.useRef(new Nt),pt=Z.useRef(new Nt),He=Z.useRef(null),[Je,pe]=Z.useState(f.vimMode?"NORMAL":""),[ke,Re]=Z.useState(null);ce.current=E,Ie.current=T,ot.current=D,Te.current=z,qe.current=W,Ye.current=ie,be.current=M,ht.current=m;const ne=(I,X)=>{if(He.current?.(),He.current=null,!X){pe("");return}const G=oi(I);if(!G){pe("NORMAL");return}const $=()=>{const U=G.state.vim?.mode??(G.state.vim?.insertMode?"insert":"normal");pe(U.toUpperCase())};$(),G.on("vim-mode-change",$),He.current=()=>G.off("vim-mode-change",$)};return Z.useEffect(()=>{if(!he.current)return;const I=/\.bib$/i.test(n),X=A&&!o?A.undoManager??null:null,G=Dt.create({doc:A?.text.toString()??t,extensions:[Zo(),Yo(),...A?[]:[Jo()],Go(),ea(),ta(),I?[Js,...hi(Ys(Q))]:sl,na(ga),...I?[]:[Wr(),jr.high(fe.inputHandler.of(xl)),Sl,kl],ra(),ia(),fc,dc,pc,ze.current.of(Ct.of(_r(n,Q))),gc,P.current.of(f.mathPreviewOnHover&&Or(n)?xr({loading:Q("editor.mathPreviewLoading"),unavailable:Q("editor.mathPreviewUnavailable"),preview:Q("editor.mathPreview")}):[]),oa({top:!1}),bc(Q),Dt.phrases.of(yc(Q)),aa({override:[I?Zs:$=>cc($,Q,ht.current)],activateOnTyping:!0}),...X?[An.of({undo:()=>X.undo()!==null,redo:()=>X.redo()!==null})]:[],pt.current.of(f.vimMode?gr():[]),sa.of([...la,...ca,...ua,...fa,...A&&!o?ls:[],...da,...A?[]:ha]),...A?[cs(A.text,A.awareness,{undoManager:X??!1})]:[],Dt.readOnly.of(o),Et.current.of($r(f,S)),fe.domEventHandlers({mousedown($){const U=Dr($.target);return!U||!($.ctrlKey||$.metaKey)?!1:($.preventDefault(),qe.current(U),!0)},mousemove($,U){const re=Dr($.target);return U.dom.classList.toggle("cm-reference-navigation-active",!!(re&&($.ctrlKey||$.metaKey))),!1},mouseleave($,U){return U.dom.classList.remove("cm-reference-navigation-active"),!1},click($){const U=$.target.closest("[data-comment-id]");return U?.dataset.commentId&&ot.current(U.dataset.commentId),!1},contextmenu($){const U=$.target.closest("[data-spell-error]");if(!U)return!1;const re=Number(U.dataset.spellFrom),Ge=Number(U.dataset.spellTo),at=be.current.find(Tt=>Tt.from===re&&Tt.to===Ge);if(!at)return!1;$.preventDefault();const Lt=250,ue=Math.min(300,100+at.suggestions.length*34);return Re({issue:at,left:Math.max(8,Math.min($.clientX,window.innerWidth-Lt-8)),top:Math.max(8,Math.min($.clientY,window.innerHeight-ue-8))}),!0},blur($,U){const re=U.state.selection.main;return Ie.current(U.state.sliceDoc(re.from,re.to),re.from,re.to),A?.awareness.setLocalStateField("cursor",null),!1}}),fe.updateListener.of($=>{const U=$.transactions.some(re=>re.annotation(Fr));if($.docChanged&&!U&&!A&&ce.current($.state.doc.toString()),$.docChanged&&Re(null),$.selectionSet||$.docChanged){const re=$.state.selection.main;Ie.current($.state.sliceDoc(re.from,re.to),re.from,re.to);const Ge=$.state.doc.lineAt(re.head);Ye.current(Ge.number,re.head-Ge.from+1,re.head)}})]});return J.current=new fe({state:G,parent:he.current}),ne(J.current,f.vimMode),J.current.dispatch({effects:Cn.of(Qr(s))}),()=>{He.current?.(),He.current=null,J.current?.destroy(),J.current=null}},[n,o,de.resolvedLanguage,A?.text]),Z.useEffect(()=>{const I=J.current;I&&(I.dispatch({effects:[Et.current.reconfigure($r(f,S)),ze.current.reconfigure(Ct.of(_r(n,Q))),P.current.reconfigure(f.mathPreviewOnHover&&Or(n)?xr({loading:Q("editor.mathPreviewLoading"),unavailable:Q("editor.mathPreviewUnavailable"),preview:Q("editor.mathPreview")}):[]),pt.current.reconfigure(f.vimMode?gr():[])]}),ne(I,f.vimMode))},[f,S,n,de.resolvedLanguage]),Z.useEffect(()=>{const I=J.current;if(!I)return;const X=I.state.doc.toString(),G=M.filter($=>$.from>=0&&$.to<=X.length&&$.to>$.from);I.dispatch({effects:[Ei.of(G),On.of(null)]})},[M]),Z.useEffect(()=>{Re(null)},[M]),Z.useEffect(()=>{if(!ke)return;const I=J.current,X=U=>{U.target instanceof Element&&U.target.closest(".spell-suggestions-menu")||Re(null)},G=U=>{U.key==="Escape"&&Re(null)},$=()=>Re(null);return document.addEventListener("mousedown",X,!0),document.addEventListener("keydown",G,!0),I?.scrollDOM.addEventListener("scroll",$,{passive:!0}),()=>{document.removeEventListener("mousedown",X,!0),document.removeEventListener("keydown",G,!0),I?.scrollDOM.removeEventListener("scroll",$)}},[ke,n]),Z.useEffect(()=>{const I=J.current;A||!I||I.state.doc.toString()===t||I.dispatch({changes:{from:0,to:I.state.doc.length,insert:t},annotations:Fr.of(!0)})},[t,A]),Z.useEffect(()=>{J.current?.dispatch({effects:Cn.of(Qr(s))})},[s]),Z.useEffect(()=>{const I=J.current;if(!I||!c||c.orphaned)return;const X=Math.min(c.startOffset,I.state.doc.length),G=Math.min(Math.max(X,c.endOffset),I.state.doc.length);I.dispatch({selection:{anchor:X,head:G},effects:fe.scrollIntoView(X,{y:"center"})}),I.focus()},[c]),Z.useEffect(()=>{const I=J.current;if(!I||!v)return;const X=Math.max(1,Math.min(I.state.doc.lines,v.line)),G=I.state.doc.line(X),$=Math.min(G.to,G.from+Math.max(0,v.column-1));I.dispatch({selection:{anchor:G.from,head:G.to},effects:fe.scrollIntoView($,{y:"center",yMargin:60})}),I.focus()},[v?.nonce]),Z.useEffect(()=>{const I=J.current;if(!I||!R)return;const X=Math.max(0,Math.min(R.from,I.state.doc.length)),G=Math.max(X,Math.min(R.to,I.state.doc.length));I.dispatch({selection:{anchor:X},effects:[On.of({from:X,to:G}),fe.scrollIntoView(X,{y:"center",yMargin:60})]}),I.focus()},[R?.nonce]),Z.useEffect(()=>{const I=J.current;!I||b===0||b===Mt.current||(Mt.current=b,pa(I))},[b]),Ke.jsxs("div",{className:"editor-shell",style:{fontFamily:Oa(f.font),fontSize:`${f.fontSize}px`,lineHeight:f.lineHeight},children:[Ke.jsx("div",{className:"editor-host",ref:he}),ke&&Ke.jsxs("div",{className:"spell-suggestions-menu",role:"menu","aria-label":Q("editor.writingSuggestions"),onMouseDown:I=>I.stopPropagation(),children:[Ke.jsx("div",{className:"spell-suggestions-title",children:Q("editor.writingSuggestions")}),ke.issue.message&&Ke.jsx("div",{className:"spell-suggestions-message",children:ke.issue.message}),ke.issue.suggestions.map((I,X)=>Ke.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?Q("editor.spellCheckReadOnly"):Q("editor.replaceWith",{word:I||Q("editor.removeText")}),onClick:()=>{Te.current(ke.issue,I),Re(null)},children:I||Q("editor.removeText")},`${I}-${X}`)),ke.issue.suggestions.length===0&&Ke.jsx("span",{className:"spell-suggestions-empty",children:Q("editor.noWritingSuggestions")}),o&&ke.issue.suggestions.length>0&&Ke.jsx("span",{className:"spell-suggestions-readonly",children:Q("editor.spellCheckReadOnly")})]}),f.vimMode&&Ke.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:Ke.jsxs("span",{children:["--",Je||"NORMAL","--"]})})]})}function yc(t){return{Find:t("editor.search.find"),Replace:t("editor.search.replace"),next:t("editor.search.next"),previous:t("editor.search.previous"),all:t("editor.search.all"),"match case":t("editor.search.matchCase"),regexp:t("editor.search.regexp"),"by word":t("editor.search.wholeWord"),replace:t("editor.search.replaceNext"),"replace all":t("editor.search.replaceAll"),close:t("common.close"),"current match":t("editor.search.currentMatch"),"on line":t("editor.search.onLine"),"replaced match on line $":t("editor.search.replacedMatchOnLine"),"replaced $ matches":t("editor.search.replacedMatches"),"Go to line":t("editor.search.goToLine"),go:t("editor.search.go")}}function bc(t){return dt.fromClass(class{constructor(n){this.view=n,this.document=n.state.doc,this.schedule()}view;frame=null;document;signature="";count=0;update(){this.schedule()}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame)}schedule(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()})}render(){if(!ma(this.view.state))return;const n=this.view.dom.querySelector(".cm-panel.cm-search");if(!n)return;let o=n.querySelector(".cm-search-count");if(!o){o=document.createElement("span"),o.className="cm-search-count",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const f=n.querySelector("[name=close]");n.insertBefore(o,f)}const s=va(this.view.state),c=fs(s);(this.document!==this.view.state.doc||this.signature!==c)&&(this.document=this.view.state.doc,this.signature=c,this.count=us(this.view.state,s)),o.textContent=s.search?s.valid?this.count===0?t("editor.search.noMatches"):t("editor.search.matchCount",{count:this.count}):t("editor.search.invalidQuery"):""}})}function $r(t,n){return[fe.contentAttributes.of({spellcheck:n?"true":"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),fe.theme({"&":{fontSize:`${t.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),t.lineWrapping?fe.lineWrapping:[]]}function _r(t,n){return{enabled:/\.(?:tex|sty|cls)$/i.test(t),title:s=>s.kind==="citation"?n("editor.citationJumpHint",{key:s.key}):n("editor.labelJumpHint",{key:s.key})}}function kc(t,n){const o=t.map(s=>({from:Math.max(0,Math.min(n,s.from)),to:Math.max(0,Math.min(n,s.to)),word:s.word,kind:s.kind,message:s.message})).filter(s=>s.to>s.from).sort((s,c)=>s.from-c.from||s.to-c.to);return Y.set(o.map(s=>Y.mark({class:s.kind==="spelling"?"cm-spell-error":"cm-grammar-warning",attributes:{title:s.message||s.word,"data-spell-error":"true","data-spell-kind":s.kind,"data-spell-from":String(s.from),"data-spell-to":String(s.to)}}).range(s.from,s.to)),!0)}function Qr(t){return t.map(n=>({id:n.id,from:n.startOffset,to:n.endOffset,resolved:n.resolved,orphaned:n.orphaned}))}function Cc(t,n){const o=t.filter(s=>!s.orphaned&&!s.resolved).flatMap(s=>{const c=Math.max(0,Math.min(n,s.from)),f=Math.max(c,Math.min(n,s.to)),m="cm-source-comment";return c===f?[Y.widget({widget:new Kr(s.id,m),side:1}).range(c)]:[Y.mark({class:m}).range(c,f),Y.widget({widget:new Kr(s.id,m),side:1}).range(f)]});return Y.set(o,!0)}class Kr extends zr{constructor(n,o){super(),this.id=n,this.className=o}id;className;toDOM(){const n=document.createElement("span");return n.className=`${this.className} cm-comment-pin`,n.dataset.commentId=this.id,n.textContent="●",n}}export{Ac as LatexEditor};
|